Skip to main content

A hatch plugin to help build Jupyter packages

Project description

hatch-jupyter-builder

PyPI - Version PyPI - Python Version


This provides a build hook plugin for Hatch that adds a build step for use with Jupyter packages.

Table of Contents

Installation

pip install hatch-jupyter-builder

License

hatch-jupyter-builder is distributed under the terms of the MIT license.

Usage and Configuration

The build hook plugin name is jupyter-builder.

  • pyproject.toml

    [tool.hatch.build.hooks.jupyter-builder]
    dependencies = ["hatch-jupyter-builder"]
    build-function = "hatch_jupyter_builder.npm_builder"
    ensured-targets = ["foo/generated.txt"]
    install-pre-commit-hook = true
    
    [tool.hatch.build.hooks.jupyter-builder.build-kwargs]
    build_cmd = "build:src"
    

Options

The only required fields are dependencies and build-function. The build function is defined as an importable string with a module and a function name, separated by a period. The function must accept a target_name (either "wheel" or "sdist"), and a version (either "standard" or "editable") as its only positional arguments. E.g.

  • builder.py

    def build_func(target_name, version):
        ...
    

Would be defined as build-function = "builder.build_func"

The optional ensured-targets is a list of expected file paths after building a "standard" version sdist or wheel.

The optional skip-if-exists is a list of paths whose presence would cause the build step to be skipped. This option is ignored in editable mode. The ensured-targets will still be checked, if given.

The optional build-kwargs is a set of keyword arguments to pass to the build function.

You can also use editable-build-kwargs if the parameters should differ in editable mode. If only the build command is different, you can use editable_build_cmd in build-kwargs instead.

The optional install-pre-commit-hook boolean causes a pre-commit hook to be installed during an editable install.

Npm Builder Function

This library provides a convenenice npm_builder function which can be used to build npm assets as part of the build.

Migration

This library can be used to migrate from a setuptools based package to use hatch_jupyter_builder. It will attempt to migrate jupyter-packaging config as well, if present.

To migrate, run the following:

python -m hatch_jupyter_builder.migration .

The migration script will do most of the migration automatically, but will prompt you for anything it cannot do itself.

To compare dist files with a reference checkout, run the following:

python -m hatch_jupyter_builder.migration.compare <source_dir> <target_dir> sdist

Use wheel to compare wheel file contents.

Local Development

To test this package locally with another package, use the following:

[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder@file://<path_to_this_repo>"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatch_jupyter_builder-0.5.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

hatch_jupyter_builder-0.5.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file hatch_jupyter_builder-0.5.0.tar.gz.

File metadata

  • Download URL: hatch_jupyter_builder-0.5.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for hatch_jupyter_builder-0.5.0.tar.gz
Algorithm Hash digest
SHA256 28b6f7a988e9ad9c3664a6dbc18ed27bd4bfe200c58fefef1bc81db386187deb
MD5 33bdc3f8ddd4a421959e920f2f0081b2
BLAKE2b-256 d690ef423af5b31e566800bfed1113da494a12c9e2c9c036d10bfe2e102fbd8c

See more details on using hashes here.

File details

Details for the file hatch_jupyter_builder-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_jupyter_builder-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c44a77d35d1bf87ccffee55b7d61aa35355f77a569c28bc46cf44edf1946157
MD5 422897ee4ee131bfd3c0cc8fa984b3cb
BLAKE2b-256 406c91704b4a10b9af2db502338886f75ffdf0633ad0d3a940c5411c8d8b8b09

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page