hatch_jupyter_builder package#
Subpackages#
Submodules#
The cli implementation for hatch_jupyter_builder.
- hatch_jupyter_builder.cli.make_parser(parser=None, prog=None)#
Make an arg parser.
- Return type:
ArgumentParser
- hatch_jupyter_builder.cli.run(args=None)#
Run the main script.
- Return type:
None
Register hooks for the plugin.
- hatch_jupyter_builder.hooks.hatch_register_build_hook()#
Get the hook implementation.
- Return type:
Type
[JupyterBuildHook
]
The main plugin for hatch_jupyter_builder.
- class hatch_jupyter_builder.plugin.JupyterBuildConfig(install_pre_commit_hook='', build_function=None, build_kwargs=<factory>, editable_build_kwargs=<factory>, ensured_targets=<factory>, skip_if_exists=<factory>, optional_editable_build='')#
Bases:
BuilderConfig
Build config values for Hatch Jupyter Builder.
- build_function: str | None = None#
- build_kwargs: t.Mapping[str, str]#
- editable_build_kwargs: t.Mapping[str, str]#
- ensured_targets: list[str]#
- install_pre_commit_hook: str = ''#
- optional_editable_build: str = ''#
- skip_if_exists: list[str]#
- class hatch_jupyter_builder.plugin.JupyterBuildHook(root, config, build_config, metadata, directory, target_name, app=None)#
Bases:
BuildHookInterface
[JupyterBuildConfig
]The hatch jupyter builder build hook.
- PLUGIN_NAME = 'jupyter-builder'#
The name used for selection.
- initialize(version, _)#
Initialize the plugin.
- Return type:
None
Utilities for hatch_jupyter_builder.
- hatch_jupyter_builder.utils.compare_recursive_mtime(path, cutoff, newest=True)#
Compare the newest/oldest mtime for all files in a directory. Cutoff should be another mtime to be compared against. If an mtime that is newer/older than the cutoff is found it will return True. E.g. if newest=True, and a file in path is newer than the cutoff, it will return True.
- Return type:
bool
- hatch_jupyter_builder.utils.ensure_targets(ensured_targets)#
Ensure that target files are available
- Return type:
None
- hatch_jupyter_builder.utils.get_build_func(build_func_str)#
Get a build function by name.
- Return type:
Callable
[...
,None
]
- hatch_jupyter_builder.utils.install_pre_commit_hook()#
Install a pre-commit hook.
- Return type:
None
- hatch_jupyter_builder.utils.is_stale(target, source)#
Test whether the target file/directory is stale based on the source file/directory.
- Return type:
bool
- hatch_jupyter_builder.utils.list2cmdline(cmd_list)#
Implementation of list2cmdline for posix systems.
- Return type:
str
- hatch_jupyter_builder.utils.mtime(path)#
shorthand for mtime
- Return type:
float
- hatch_jupyter_builder.utils.normalize_cmd(cmd)#
Normalize a subprocess command.
- Return type:
list
[str
]
- hatch_jupyter_builder.utils.normalize_kwargs(kwargs)#
Normalize the key names in a kwargs input dictionary
- Return type:
dict
[str
,Any
]
- hatch_jupyter_builder.utils.npm_builder(target_name, version, path='.', build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None, editable_build_cmd=None)#
Build function for managing an npm installation.
- Parameters:
target_name (str) – The build target name (“wheel” or “sdist”).
version (str) – The version name (“standard” or “editable”).
path (str, optional) – The base path of the node package. Defaults to the current directory.
build_dir (str, optional) – The target build directory. If this and source_dir are given, the JavaScript will only be built if necessary.
source_dir (str, optional) – The source code directory.
build_cmd (str, optional) – The npm command to build assets to the build_dir.
editable_build_cmd (str, optional.) – The npm command to build assets to the build_dir when building in editable mode.
npm (str or list, optional.) – The npm executable name, or a tuple of [‘node’, executable].
- Return type:
None
Notes
- The function is a no-op if the –skip-npm cli flag is used
or HATCH_JUPYTER_BUILDER_SKIP_NPM env is set.
- hatch_jupyter_builder.utils.recursive_mtime(path, newest=True)#
Gets the newest/oldest mtime for all files in a directory.
- Return type:
float
- hatch_jupyter_builder.utils.run(cmd, **kwargs)#
Echo a command before running it.
- Return type:
int
- hatch_jupyter_builder.utils.should_skip(skip_if_exists)#
Detect whether all the paths in skip_if_exists exist
- Return type:
bool