Registry / devops / jupyter-packaging

jupyter-packaging

JSON →
library0.12.3pypypi✓ verified 23d ago

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-packaging
INSTALL
IMPORT
SIG · JUPYTER-PACKAGING
J
jupyter-packaging
devopspythonv0.12.3
Install
2.0s avg
Import
862ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.12.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.942s · 20.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.782s · 21MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wrap_installers
from jupyter_packaging import wrap_installers
Used to wrap setuptools commands like 'install' or 'develop' with pre- and post-build steps.
npm_builder
from jupyter_packaging import npm_builder
A utility builder class for executing Node.js package manager commands (npm or yarn) as part of the build process.
bdist_wheel
from setuptools.command.bdist_wheel import bdist_wheel
from wheel.bdist_wheel import bdist_wheel
As of `setuptools` v61.0.0, `bdist_wheel` moved from the `wheel` package into `setuptools` itself. `jupyter-packaging` v0.12.0 updated its internal import path to reflect this, but older versions of `jupyter-packaging` might break if used with newer `setuptools` versions.

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.

from setuptools import setup try: from jupyter_packaging import wrap_installers, npm_builder # Define the builder for npm commands # Assumes a package.json in the root that defines 'build' and 'build:dev' scripts builder = npm_builder(build_cmd='build', develop_cmd='build:dev') # Wrap the 'install' and 'develop' commands with the npm builder cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder) except ImportError: # Fallback for when jupyter_packaging is not available (e.g., during sdist build) cmdclass = {} setup( name='my_jupyter_extension', version='0.1.0', cmdclass=cmdclass, # Other setup arguments like packages, include_package_data, etc. packages=['my_jupyter_extension'], include_package_data=True, # Make sure to include MANIFEST.in for data files not in Python packages # (e.g., JS/CSS assets, Jupyter config files) )
Debug
Known issues
breakingWhen upgrading `setuptools` to version 61.0.0 or higher, projects using `jupyter-packaging` versions prior to 0.12.0 may encounter `ImportError` due to a change in the internal import path for `bdist_wheel`.
fix
Upgrade `jupyter-packaging` to version 0.12.0 or later. Ensure your `setup.py` or `pyproject.toml` specifies a compatible `jupyter-packaging` version.
affects: <0.12.0
deprecatedSupport for Python 3.6 was dropped with the release of `jupyter-packaging` 0.11.0.
fix
Ensure your project targets Python 3.7 or newer. Upgrade your Python environment if necessary.
affects: <0.11.0
gotchaBuilding Jupyter extensions with front-end assets typically requires Node.js and a package manager (npm or yarn) to be installed and available in the system's PATH, as `jupyter-packaging` will execute these tools.
fix
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`).
affects: All
gotcha`jupyter-packaging` is primarily intended as a *build-time* dependency, not a *runtime* dependency. It should be listed in `build-system.requires` in `pyproject.toml` rather than `install_requires` in `setup.py` or `dependencies` in `pyproject.toml` for most projects.
fix
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.
affects: All
gotcha`jupyter-packaging` does not support the deprecated `python setup.py bdist_wheel` or `python setup.py sdist` commands directly. The recommended approach for building distributions is to use the `build` package.
fix
Instead of `python setup.py sdist` or `python setup.py bdist_wheel`, use `pip install build` followed by `python -m build .`.
affects: All
gotchaSetuptools' `data_files` (often used for Jupyter configuration files) are not fully supported in editable (`pip install -e .`) mode.
fix
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.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jupyter_packaging'
`jupyter-packaging` is typically a build dependency, not a runtime dependency. This error occurs if a package tries to import `jupyter_packaging` directly at runtime, or if it's missing from the build environment during development.
fix
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`.
'npm' is not recognized as an internal or external command, operable program or batch file
Jupyter packaging often relies on Node.js and npm (or yarn) to build front-end assets. This error indicates that Node.js and npm are either not installed or not correctly added to your system's PATH environment variable.
fix
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.
ValueError: Please install Node.js and npm before continuing installation.
This error occurs when `jupyter-packaging` or a Jupyter extension build process attempts to run an npm command (e.g., `npm install`) but cannot find the `node` or `npm` executables, often because they are missing or not in the system's PATH.
fix
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.
subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Cargo, the Rust package manager, is not installed or is not on PATH. This package requires Rust and Cargo to compile extensions.
When installing some Jupyter-related packages (like JupyterLab or its dependencies) via `pip`, a dependency might require compilation using a Rust toolchain (Cargo) if a pre-built wheel is not available for your specific Python version or operating system. This error means Rust and Cargo are not found.
fix
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.
data_files are not supported in develop mode (a limitation of setuptools).
When creating an editable (develop mode) installation (`pip install -e .`) of a package that uses `jupyter-packaging` to manage `data_files` (e.g., for Jupyter assets), `setuptools` does not properly handle the symlinking or copying of these non-Python files.
fix
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.
Upgrade
Version history
0.12.3latest on PyPI · released Aug 25, 2022
Audit
Dependencies
setuptoolsrequiredCore build dependency for integrating with Python packaging.
Node.js/npm/yarnoptionalRequired for building front-end (JavaScript/TypeScript) assets for Jupyter extensions.
Agent activity
3 hits · last 30 days
node
2
Resources
jupyter-packaging — pip install jupyter-packaging · libregistry