Build tools for JupyterLab (and remixes)
Note
This started by the extraction of the builder tools included in the core JupyterLab during a GSoC project. See below for more information.
- This would also solve some chicken-and-egg problems like jupyterlab/jupyterlab_pygments#23.
- Isolating the builder functionalities will simplify the work of core and extension developers who can now focus on their respective parts of the codebase instead of the earlier intertwined code.
- It will in particular reduce the need to update the maintenance tooling to produce extension compatible with newer version of Jupyter app.
Execute the following command in a terminal:
pip install jupyter_builder
- Provides a CLI for building Jupyter extensions. There are 3 subcommands
build: Builds the Jupyter extension JavaScript assets to be consumed by the Jupyter app.jupyter-builder build <path to extension folder>develop: Install the Jupyter extension JavaScript assets in dev mode for consumption in the Jupyter app. It similar to editable install mode of pipjupyter-builder develop --overwrite <path to extension folder>watch: Automatically rebuild the development JavaScript assets when one file is changed to ease development.jupyter-builder watch <path to extension folder>
- Provides a NPM package manager:
jlpm
Execute the following command in a terminal:
pip uninstall jupyter_builder
Written by @cronan03 - GSoC Contributor 2024
The goals of this project are:
- to extract that tooling as a new separate package to ease maintenance (for core and extension developers)
- update the existing package to use the new one
- make it configurable to be reused for other applications.
- Successfully created a CLI with the processes
develop,buildandwatchmentioned above. - Created extensive unit tests using
Pytestto ensure the processes run efficiently on any OS. - Reduced external dependencies by bringing
jlpmandjupyterlab.semverto the package. - Pre released the package. It can be found on Pypi here https://pypi.org/project/jupyter-builder/
- Initiated a solution to the issue jupyterlab/jupyterlab#13456
- We should bring
@jupyterlab/builderwithin this package and make it generic. For now the code lives there: https://github.com/jupyterlab/jupyterlab/tree/main/builder - which is responsible for checking version overlap has been temporarily ignored to make the build feature work.
- Update JupyterLab core to use this new package
- #11
- This PR focuses on extracting the
developfeature which is responsible for installing the Jupyter extension JS assets in dev mode. - Considering the size of labextension.py, only features essential to Jupyter builder were added.
- Each of the features will inherit from the class
BaseExtensionApppresent here - The federated_extensions.py sets up and executes commands to build, develop and waatch a JupyterLab extension. It resolves paths, constructs the appropriate command-line arguments, and executes the build process using
subprocess.check_call. Optional parameters allow for customization of the build process, including logging, development mode, and source map generation.
- This PR focuses on extracting the
- #13
- This PR focuses on extracting the
buildfeature which is responsible for creating the Javascript assets which will be consumed by the Jupyter App. - It will always result in the creation of a file
static/style.jsin<extension_folder>/myextension/labextension. - Tests have been crafted using
Pytestto check for the existence of files mentioned above on running thebuildcommand.
- This PR focuses on extracting the
- #18
- The
watchfeature on running will rebuild the JS assets on being triggered. This happens on changing contents in<extension_folder>/src/index.ts - To test this feature we deliberately make a change in
index.tstriggeringwatch. This replaces old JS assets with new ones having different hash values in the file names. We create 2 vectors of filenames before and after triggeringwatchwhich will tell us if it actually worked.
- The
- #20
- To reduce external dependencies, we added
jlpmto this package. - It existed here with the entrypoint.
- To reduce external dependencies, we added
- #22
- Documented the working of the Jupyter builder along with installation guide.
- One of the main challenges was starting this project from scratch with no pre existing code to rely on. I thank my mentor @fcollonval for creating the skeleton in #2 which gave me a base to work on.
- Selecting relevant features for Jupyter builder from labextension.py was really tough without a thorough understanding on which functions Jupyter builder would actually rely on.
- Creating tests for the
watchfeature was tricky as I had to carefully adjust sleep times to make sure the function was running before a change in<extension_folder>/src/index.tswas made. Otherwise the change happened beforewatchran and never triggered it.