Jupyter Packaging Utilities.
Project description
Jupyter Packaging
Tools to help build and install Jupyter Python packages that require a pre-build step that may include JavaScript build steps.
Install
pip install jupyter-packaging
Usage
There are three ways to use jupyter-packaging in another package.
As a Build Requirement
Use a pyproject.toml file as outlined in pep-518.
An example:
[build-system]
requires = ["jupyter_packaging~=0.8.0"]
build-backend = "setuptools.build_meta"
Below is an example setup.py using the above config.
It assumes the rest of your metadata is in setup.cfg.
We wrap the import in a try/catch to allow the file to be run without jupyter_packaging
so that python setup.py can be run directly when not building.
from setuptools import setup
try:
from jupyter_packaging import wrap_installers, npm_builder
builder = npm_builder()
cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)
except ImportError:
cmdclass = {}
setup(cmdclass=cmdclass))
As a Build Backend
Use the jupyter_packaging build backend.
The pre-build command is specified as metadata in pyproject.toml:
[build-system]
requires = ["jupyter_packaging~=0.8.0"]
build-backend = "jupyter_packaging.build_api"
[tool.jupyter-packaging.builder]
func = "jupyter_packaging.npm_builder"
[tool.jupyter-packaging.build-args]
build_cmd = "build:src"
The corresponding setup.py would be greatly simplified:
from setuptools import setup
setup()
The tool.jupyter-packaging.builder section expects a func value that points to an importable
module and a function with dot separators. If not given, no pre-build function will run.
The optional tool.jupyter-packaging.build-args sections accepts a dict of keyword arguments to
give to the pre-build command.
The build backend does not handle the develop command (pip install -e .).
If desired, you can wrap just that command:
import setuptools
try:
from jupyter_packaging import wrap_installers, npm_builder
builder = npm_builder(build_cmd="build:dev")
cmdclass = wrap_installers(pre_develop=builder)
except ImportError:
cmdclass = {}
setup(cmdclass=cmdclass))
As a Vendored File
Vendor setupbase.py locally alongside setup.py and import the module directly.
import setuptools
from setupbase import wrap_installers, npm_builder
builder = npm_builder
cmdclass = wrap_installers(post_develop=builder, pre_dist=builder)
setup(cmdclass=cmdclass)
Usage Notes
- We recommend using
include_package_data=TrueandMANIFEST.into control the assets included in the package. - Tools like
check-manifestormanifixcan be used to ensure the desired assets are included. - Simple uses of
data_filescan be handled insetup.cfgor insetup.py. If recursive directories are needed useget_data_files()from this package. - Unfortunately
data_filesare not supported indevelopmode (a limitation ofsetuptools). You can work around it by doing a full install (pip install .) before the develop install (pip install -e .), or by adding a script to push the data files tosys.base_prefix.
Development Install
git clone https://github.com/jupyter/jupyter-packaging.git
cd jupyter-packaging
pip install -e .
You can test changes locally by creating a pyproject.toml with the following, replacing the local path to the git checkout:
[build-system]
requires = ["jupyter_packaging@file://<path-to-git-checkout>"]
build-backend = "setuptools.build_meta"
Note: you need to run pip cache remove jupyter_packaging any time changes are made to prevent pip from using a cached version of the source.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_packaging-0.8.0.tar.gz.
File metadata
- Download URL: jupyter_packaging-0.8.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
276c9f884286695f6ab57a017f4bb9dd4df4f5e232b783050d2aa55b6b9ed650
|
|
| MD5 |
ff7fe455bffe046ea91d27d7b1cbcfbf
|
|
| BLAKE2b-256 |
99c07d7008e7f17cfde0d45026e4f7726d5c6d69d7ff2a789d7a21b8be9ff76a
|
File details
Details for the file jupyter_packaging-0.8.0-py2.py3-none-any.whl.
File metadata
- Download URL: jupyter_packaging-0.8.0-py2.py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaca541a9d81882084c867a1e6dc7c095480b0aa815d9b55e0a2edd9fa7dfbc0
|
|
| MD5 |
32a59b3d576af52c681bbde1fb2512c9
|
|
| BLAKE2b-256 |
91a59b9445c3729107d79da0ab1d9160d03478bd404010c0989b19fea6c3672c
|