Jupyter Packaging provides utility functions and `setuptools` build command classes to simplify the packaging of Jupyter applications and extensions, particularly those with front-end (JavaScript/TypeScript) assets. It helps integrate pre-build steps into the Python packaging process. The current version is 0.12.3, and it typically sees releases for bug fixes, maintenance, and enhancements related to packaging standards and dependencies.
pip install jupyter-packagingVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `jupyter-packaging` into a `setup.py` file to handle front-end build steps for a Jupyter extension. It uses `npm_builder` to define pre-build commands for both development (`develop`) and distribution (`dist`) modes, ensuring that JavaScript/TypeScript assets are compiled before the Python package is installed or built. The `try/except ImportError` block allows the `setup.py` to be run even if `jupyter-packaging` is not installed, which can be useful during initial `sdist` creation or local testing.
Upgrade `jupyter-packaging` to version 0.12.0 or later. Ensure your `setup.py` or `pyproject.toml` specifies a compatible `jupyter-packaging` version.
Ensure your project targets Python 3.7 or newer. Upgrade your Python environment if necessary.
Install Node.js (which includes npm) and optionally yarn in your build environment. Verify their availability by running `node -v` and `npm -v` (or `yarn -v`).
Configure `jupyter-packaging` as a build requirement in your `pyproject.toml` (e.g., `requires = ["jupyter_packaging>=0.10,<2"]`) or ensure it's only installed in build environments.
Instead of `python setup.py sdist` or `python setup.py bdist_wheel`, use `pip install build` followed by `python -m build .`.
For development installations, you might need to perform a full install (`pip install .`) before an editable install (`pip install -e .`), or manually link/copy data files into the appropriate locations.
Ensure `jupyter-packaging` is listed as a build dependency in `pyproject.toml` (`build-system.requires`) or installed in your development environment: `pip install jupyter-packaging`.
Install Node.js and npm from the official Node.js website or via your system's package manager. Verify installation by running `npm -v` in a new terminal, and ensure the Node.js installation directory is in your system's PATH.
Install Node.js and npm, and ensure they are accessible in your system's PATH. On Windows, this often means checking the installation options to add to PATH, or manually adding the directory where `node.exe` and `npm.cmd` reside (e.g., `C:\Program Files\nodejs\`). On Linux/macOS, ensure they are installed and your shell can find them.
Install the Rust toolchain (which includes Cargo) by following instructions on `rustup.rs`. Alternatively, if possible, use `conda install` for the package, as `conda-forge` often provides pre-built binaries, or try pinning to an older version of JupyterLab that might not have this dependency or has available wheels.
For develop mode, you might need to manually copy the `data_files` to their target location or perform a full installation (`pip install .`) instead of an editable one. The `jupyter-packaging` documentation suggests alternatives or workarounds, such as using `include_package_data=True` and `MANIFEST.in` where applicable.