{"id":13609422,"url":"https://github.com/jupyter/jupyter-packaging","last_synced_at":"2025-05-15T18:07:34.504Z","repository":{"id":18295475,"uuid":"83919624","full_name":"jupyter/jupyter-packaging","owner":"jupyter","description":"Tools to help build and install Jupyter Python packages","archived":false,"fork":false,"pushed_at":"2025-05-05T20:32:16.000Z","size":312,"stargazers_count":64,"open_issues_count":16,"forks_count":47,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-05T21:37:23.972Z","etag":null,"topics":["distutils","jupyter","packaging","python","setuptools"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jupyter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-04T19:38:49.000Z","updated_at":"2025-04-04T04:19:39.000Z","dependencies_parsed_at":"2024-01-01T23:30:14.877Z","dependency_job_id":"260c9123-c096-4be0-98e6-5abcd2f3be99","html_url":"https://github.com/jupyter/jupyter-packaging","commit_stats":{"total_commits":300,"total_committers":30,"mean_commits":10.0,"dds":0.6233333333333333,"last_synced_commit":"4915fc8e36e38111b96c23e28e37b2873ca57907"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjupyter-packaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjupyter-packaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjupyter-packaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjupyter-packaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupyter","download_url":"https://codeload.github.com/jupyter/jupyter-packaging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394722,"owners_count":22063984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distutils","jupyter","packaging","python","setuptools"],"created_at":"2024-08-01T19:01:34.786Z","updated_at":"2025-05-15T18:07:34.482Z","avatar_url":"https://github.com/jupyter.png","language":"Python","funding_links":[],"categories":["Jupyter组件","Jupyter Components"],"sub_categories":[],"readme":"# Jupyter Packaging\n\n:warning: We recommend using [Hatch Jupyter Builder](https://github.com/jupyterlab/hatch-jupyter-builder) instead of Jupyter Packaging for new and existing projects.\nSee the blog post [Packaging for Jupyter in 2022](https://blog.jupyter.org/packaging-for-jupyter-in-2022-c7be64c38926).\n\n## About\n\nTools to help build and install Jupyter Python packages that require a pre-build step that may include JavaScript build steps.\n\n## Install\n\n`pip install jupyter-packaging`\n\n## Usage\n\nThere are three ways to use `jupyter-packaging` in another package.\nIn general, you should not depend on `jupyter_packaging` as a runtime dependency, only as a build dependency.\n\n### As a Build Requirement\n\nUse a `pyproject.toml` file as outlined in [pep-518](https://www.python.org/dev/peps/pep-0518/).\nAn example:\n\n```toml\n[build-system]\nrequires = [\"jupyter_packaging\u003e=0.10,\u003c2\"]\nbuild-backend = \"setuptools.build_meta\"\n```\n\nBelow is an example `setup.py` using the above config.\nIt assumes the rest of your metadata is in [`setup.cfg`](https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html).\nWe wrap the import in a try/catch to allow the file to be run without `jupyter_packaging`\nso that `python setup.py` can be run directly when not building.\n\n```py\nfrom setuptools import setup\n\ntry:\n    from jupyter_packaging import wrap_installers, npm_builder\n    builder = npm_builder()\n    cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)\nexcept ImportError:\n    cmdclass = {}\n\nsetup(cmdclass=cmdclass))\n```\n\n### As a Build Backend\n\nUse the `jupyter_packaging` build backend.\nThe pre-build command is specified as metadata in `pyproject.toml`:\n\n```toml\n[build-system]\nrequires = [\"jupyter_packaging\u003e=0.10,\u003c2\"]\nbuild-backend = \"jupyter_packaging.build_api\"\n\n[tool.jupyter-packaging.builder]\nfactory = \"jupyter_packaging.npm_builder\"\n\n[tool.jupyter-packaging.build-args]\nbuild_cmd = \"build:src\"\n```\n\nThe corresponding `setup.py` would be greatly simplified:\n\n```py\nfrom setuptools import setup\nsetup()\n```\n\nThe `tool.jupyter-packaging.builder` section expects a `func` value that points to an importable\nmodule and a function with dot separators.  If not given, no pre-build function will run.\n\nThe optional `tool.jupyter-packaging.build-args` sections accepts a dict of keyword arguments to\ngive to the pre-build command.\n\nThe build backend does not handle the `develop` command (`pip install -e .`).\nIf desired, you can wrap just that command:\n\n```py\nimport setuptools\n\ntry:\n    from jupyter_packaging import wrap_installers, npm_builder\n    builder = npm_builder(build_cmd=\"build:dev\")\n    cmdclass = wrap_installers(pre_develop=builder)\nexcept ImportError:\n    cmdclass = {}\n\nsetup(cmdclass=cmdclass))\n```\n\nThe optional `tool.jupyter-packaging.options` section accepts the following options:\n\n- `skip-if-exists`: A list of local files whose presence causes the prebuild to skip\n- `ensured-targets`: A list of local file paths that should exist when the dist commands are run\n\n### As a Vendored File\n\nVendor `setupbase.py` locally alongside `setup.py` and import the module directly.\n\n```py\nimport setuptools\nfrom setupbase import wrap_installers, npm_builder\nfunc = npm_builder()\ncmdclass = wrap_installers(post_develop=func, pre_dist=func)\nsetup(cmdclass=cmdclass)\n```\n\n## Usage Notes\n\n- This package does not work with the deprecated `python setup.py bdist_wheel` or `python setup.py sdist` commands, PyPA recommends using the [build](https://pypa-build.readthedocs.io/en/latest/index.html) package (`pip install build \u0026\u0026 python -m build .`).\n- We recommend using `include_package_data=True` and `MANIFEST.in` to control the assets included in the [package](https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html).\n- Tools like [`check-manifest`](https://github.com/mgedmin/check-manifest) or [`manifix`](https://github.com/vidartf/manifix) can be used to ensure the desired assets are included.\n- Simple uses of `data_files` can be handled in `setup.cfg` or in `setup.py`.  If recursive directories are needed use `get_data_files()` from this package.\n- Unfortunately `data_files` are not supported in `develop` mode (a limitation of `setuptools`).  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 to `sys.base_prefix`.\n\n## Development Install\n\n```bash\ngit clone https://github.com/jupyter/jupyter-packaging.git\ncd jupyter-packaging\npip install -e .[test]\npre-commit install\n```\n\nYou can test changes locally by creating a `pyproject.toml` with the following, replacing the local path to the git checkout:\n\n```toml\n[build-system]\nrequires = [\"jupyter_packaging@file://\u003cpath-to-git-checkout\u003e\"]\nbuild-backend = \"setuptools.build_meta\"\n```\n\nNote: 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupyter%2Fjupyter-packaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupyter%2Fjupyter-packaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupyter%2Fjupyter-packaging/lists"}