jupyterlab / hatch-jupyter-builder Goto Github PK
View Code? Open in Web Editor NEWA hatch plugin to help build Jupyter packages
Home Page: https://hatch-jupyter-builder.readthedocs.io/en/latest/
License: BSD 3-Clause "New" or "Revised" License
A hatch plugin to help build Jupyter packages
Home Page: https://hatch-jupyter-builder.readthedocs.io/en/latest/
License: BSD 3-Clause "New" or "Revised" License
I have had a lot of trouble trying to package and deploy jupyterlab widgets. Particularly around "module not found errors". There are many moving parts to a widget, and it would be nice to know at build time what doesn't line up.
From my investigations I can see module names pop up in the following places
package.json
-> name
this is imported into js
or src
version.ts
as MODULE_NAME
MODULE_NAME
is used in
DOMWidgetModel
extending models on the js/ts side
MODULE_NAME
is also used in plugin.ts
in the activateWidgetExtension
function via registry.registerWidget
There is also an EXTENSION_ID
used for IPlugin
Then on the python side there is
_frontend.py
which references a hardcoded module_name
finally in ipydatagrid.json
there is the following form
"load_extensions": {
"ipydatagrid/extension": true
}
}
I think this gets converted into an install.json
I am trying to take the ipydatagrid repo as a baseline and first strip out everything to a very simple installable pip package (with it's own repo).
Then I want to put my ipywidget on to of that repo.
Another way of stating this is: "When I look at an existing working repo for an ipywidget - like ipydatagrid. I see the string ipydatagrid
repeated in a variety of locations referencing different things - a python module, the name of an npm package, the MODULE_NAME
of an ipywidget. and as part of the string of some type of jupyter notebook registration piece".
I understand that by convention ipydatagrid
will be the same in each place, it would be nice to read an explanation of the true meaning of each occurence.
There should be some type of check command included with hatch-jupyter-builder that will make a good faith attempt to verify that all of these strings line up properly.
I filed a related bug against widget-ts-cookiecutter
jupyter-widgets/widget-ts-cookiecutter#131
Following up from jupyterlab/jupyterlab#12606
Remaining steps:
I have seen a lot of docs about "how to make a jupyterlab extension" and "how to make an ipywidget". Most of them use hatch-jupyter-builder in some form.
The configuration options are listed "just so", without an explanation of what the different options do.
I have some idea that when a package built with hatch-jupyter-builder is pip install
ed, there are some sequence of commands executed similar to
jupyter labextension develop --overwrite .
It would be helpful to list which exact commands are executed, so a user of hatch-jupyter-builder understand the individual steps and what is going wrong.
Step by step explanation of what hatch-jupyter-builder does.
Running:
python -m hatch_jupyter_builder.migrate .
On a project that doesn't have a pyproject.toml
file yet fails with:
Starting pyproject.toml migration
Traceback (most recent call last):
File "/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/hatch_jupyter_builder/migrate/_migrate.py", line 27, in <module>
data = tomli.loads(pyproject.read_text("utf-8"))
File "/home/gitpod/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 1236, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
File "/home/gitpod/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 1222, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/home/gitpod/.pyenv/versions/3.8.13/lib/python3.8/pathlib.py", line 1078, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'
Repo with a setup.cfg
and / or setup.py
.
pyproject.toml
should be created if needed.
I tried to setup a jupyterlab extension to install jupyterlab from a branch. To use portal in yarn I wanted to use submodule. Submodule has .git
file which is not a folder so precommit hook fails. It would be good to have a way to ignore this failure as currently it just errors out installation
× Preparing editable metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [30 lines of output]
INFO:hatch_jupyter_builder.utils:Running jupyter-builder
INFO:hatch_jupyter_builder.utils:Writing pre-commit hook
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 167, in prepare_metadata_for_build_editable
hook = backend.prepare_metadata_for_build_editable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 176, in prepare_metadata_for_build_editable
whl_basename = build_hook(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-vk89r8tu/overlay/lib/python3.11/site-packages/hatchling/build.py", line 78, in build_editable
return os.path.basename(next(builder.build(wheel_directory, ['editable'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-vk89r8tu/overlay/lib/python3.11/site-packages/hatchling/builders/plugin/interface.py", line 150, in build
build_hook.initialize(version, build_data)
File "/tmp/pip-build-env-vk89r8tu/normal/lib/python3.11/site-packages/hatch_jupyter_builder/plugin.py", line 59, in initialize
install_pre_commit_hook()
File "/tmp/pip-build-env-vk89r8tu/normal/lib/python3.11/site-packages/hatch_jupyter_builder/utils.py", line 265, in install_pre_commit_hook
with open(path, "w") as fid:
^^^^^^^^^^^^^^^
NotADirectoryError: [Errno 20] Not a directory: '.git/hooks/pre-commit'
[end of output]
I tried to install a development copy of my widget into a new environment and I started receiving yarn error messages:
File "/private/var/folders/th/jfr8ccjx09g2j_18ty_t3xnh0000gn/T/pip-build-env-5brsgk98/normal/lib/python3.11/site-packages/hatch_jupyter_builder/utils.py", line 229, in run
return subprocess.check_call(cmd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/paddy/opt/anaconda3/envs/buckaroo-ipyr-dev/lib/python3.11/subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/opt/homebrew/bin/yarn', 'install']' died with <Signals.SIGSEGV: 11>.
error: subprocess-exited-with-error
× Preparing editable metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /Users/paddy/opt/anaconda3/envs/buckaroo-ipyr-dev/bin/python /Users/paddy/opt/anaconda3/envs/buckaroo-ipyr-dev/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_editable /var/folders/th/jfr8ccjx09g2j_18ty_t3xnh0000gn/T/tmptfzvgnu3
cwd: /Users/paddy/buckaroo
Preparing editable metadata (pyproject.toml) ... error
error: metadata-generation-failed
even though running yarn install
worked successfully.
Previously I had tried to remove the homebrew
installed node on my system and release it with the https://nodejs.org/en/download packaged node.
I checked for the executable of node
npm
and yarn
with which yarn
yarn pointed at /opt/homebrew/bin/yarn
and node pointed at /usr/local/bin/node
I moved yarn and npm with mv /opt/homebrew/bin/npm /opt/homebrew/bin/npm_old
mv /opt/homebrew/bin/yarn /opt/homebrew/bin/yarn_old
and verified that my path then pointed at /usr/local/bin/npm
finally I ran npm install -g yarn
.
After that
pip install -ve .
worked properly.
I think my environment was messed up. I'm writing this bug report to help anyone else who runs across this problem when developing a widget.
installing yarn via conda may have worked. This is the recommended technique by ipyreact
conda create -n ipyreact-dev -c conda-forge nodejs yarn python jupyterlab
The migration script currently defines some tbump
configuration by default:
hatch-jupyter-builder/hatch_jupyter_builder/migrate/_migrate.py
Lines 172 to 191 in ba9f6fe
Since hatch
supports versioning, it could be interesting to use hatch
by default instead.
Spotted when using the migration script recently.
First of all currently it is not possible to use straight sphinx-build
command to build documentation out of source tree
+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v6.2.1
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 354, in eval_config_file
exec(code, namespace) # NoQA: S102
File "/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/docs/conf.py", line 25, in <module>
__version__ = package_version("hatch_jupyter_builder")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: hatch_jupyter_builder
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/cmd/build.py", line 280, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/usr/lib/python3.8/site-packages/sphinx/application.py", line 207, in __init__
self.config = Config.read(self.confdir, confoverrides or {}, self.tags)
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 177, in read
namespace = eval_config_file(filename, tags)
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 367, in eval_config_file
raise ConfigError(msg % traceback.format_exc()) from exc
sphinx.errors.ConfigError: There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 354, in eval_config_file
exec(code, namespace) # NoQA: S102
File "/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/docs/conf.py", line 25, in <module>
__version__ = package_version("hatch_jupyter_builder")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: hatch_jupyter_builder
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 354, in eval_config_file
exec(code, namespace) # NoQA: S102
File "/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/docs/conf.py", line 25, in <module>
__version__ = package_version("hatch_jupyter_builder")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: hatch_jupyter_builder
This can be fixed by patch like below:
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -9,10 +9,11 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-#
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))
+
+import os
+import sys
+sys.path.insert(0, os.path.abspath(".."))
+
from importlib.metadata import version as package_version
# -- Project information -----------------------------------------------------
This patch fixes what is in the comment and that can of fix is suggested in sphinx example copy.py https://www.sphinx-doc.org/en/master/usage/configuration.html#example-of-configuration-file
Than .. on building my packages I'm using sphinx-build
command with -n
switch which shows warmings about missing references. These are not critical issues.
Here is the output with warnings:
+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v6.2.1
making output directory... done
myst v1.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'html_image'}, disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output...
building [man]: all manpages
updating environment: [new config] 13 added, 0 changed, 0 removed
reading sources... [100%] source/reference/index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-hatch-jupyter-builder.3 { source/background/index source/get_started/index source/get_started/config source/how_to_guides/index source/how_to_guides/migrating_javascript_projects source/how_to_guides/migrating_data_files_projects source/reference/index source/reference/api/modules source/reference/api/hatch_jupyter_builder source/reference/api/hatch_jupyter_builder.compare_migrated source/reference/api/hatch_jupyter_builder.migrate source/reference/changelog } /home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/compare_migrated/cli.py:docstring of hatch_jupyter_builder.compare_migrated.cli.make_parser:4: WARNING: py:class reference target not found: argparse.ArgumentParser
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/migrate/cli.py:docstring of hatch_jupyter_builder.migrate.cli.make_parser:4: WARNING: py:class reference target not found: argparse.ArgumentParser
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/cli.py:docstring of hatch_jupyter_builder.cli.make_parser:4: WARNING: py:class reference target not found: argparse.ArgumentParser
<unknown>:1: WARNING: py:data reference target not found: typing.Optional
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/plugin.py:docstring of hatch_jupyter_builder.plugin.JupyterBuildHook:1: WARNING: py:class reference target not found: hatchling.builders.hooks.plugin.interface.BuildHookInterface
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.get_build_func:4: WARNING: py:data reference target not found: typing.Callable
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.get_build_func:4: WARNING: py:data reference target not found: Ellipsis
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.normalize_kwargs:4: WARNING: py:data reference target not found: typing.Any
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional.
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/hatch_jupyter_builder/utils.py:docstring of hatch_jupyter_builder.utils.npm_builder:1: WARNING: py:class reference target not found: optional.
done
build succeeded, 14 warnings.
You can peak on fixes that kind of issues in other projects
RDFLib/rdflib-sqlalchemy#95
RDFLib/rdflib#2036
click-contrib/sphinx-click@abc31069
frostming/unearth#14
jaraco/cssutils#21
latchset/jwcrypto#289
latchset/jwcrypto#289
pypa/distlib@98b9b89f
pywbem/pywbem#2895
sissaschool/elementpath@bf869d9e
sissaschool/xmlschema@42ea98f2
sqlalchemy/sqlalchemy@5e88e6e8
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with --no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with -m "not network"
)Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-hatch-jupyter-builder-0.8.3-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-hatch-jupyter-builder-0.8.3-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3
configfile: pyproject.toml
testpaths: tests/
plugins: mock-3.11.1
collected 33 items
tests/test_is_stale.py ............ [ 36%]
tests/test_migration.py ss [ 42%]
tests/test_npm_builder.py .......... [ 72%]
tests/test_plugin.py .F [ 78%]
tests/test_utils.py ....... [100%]
=================================== FAILURES ===================================
_______________________________ test_hatch_build _______________________________
tmp_path = PosixPath('/tmp/pytest-of-tkloczko/pytest-47/test_hatch_build0')
@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="Does not work on PyPy")
def test_hatch_build(tmp_path):
> venv.create(tmp_path, with_pip=True)
/home/tkloczko/rpmbuild/BUILD/hatch-jupyter-builder-0.8.3/tests/test_plugin.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/venv/__init__.py:391: in create
builder.create(env_dir)
/usr/lib64/python3.8/venv/__init__.py:68: in create
self._setup_pip(context)
/usr/lib64/python3.8/venv/__init__.py:289: in _setup_pip
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
/usr/lib64/python3.8/subprocess.py:415: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/tmp/pytest-of-tkloczko/pytest-47/test_hatch_build0/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip'],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <subprocess.Popen object at 0x7ff1b6dada00>
stdout = b'Traceback (most recent call last):\n File "/usr/lib64/python3.8/runpy.py", line 185, in _run_module_as_main\n mo...n\n return str(max(_wheels[pkg], key=distutils.version.LooseVersion))\nValueError: max() arg is an empty sequence\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/tmp/pytest-of-tkloczko/pytest-47/test_hatch_build0/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
/usr/lib64/python3.8/subprocess.py:516: CalledProcessError
============================= slowest 10 durations =============================
0.05s call tests/test_plugin.py::test_hatch_build
0.01s call tests/test_utils.py::test_run
(8 durations < 0.005s hidden. Use -vv to show these durations.)
=========================== short test summary info ============================
SKIPPED [2] tests/conftest.py:25: Skipping this test because it's marked 'migration_test'. Run integration tests using the `--migration-tests` flag.
FAILED tests/test_plugin.py::test_hatch_build - subprocess.CalledProcessError: Command '['/tmp/pytest-of-tkloczko/pytest-47...
=================== 1 failed, 30 passed, 2 skipped in 0.41s ====================
Here is list of installed modules in build env
Package Version
----------------------------- ---------
alabaster 0.7.13
Babel 2.12.1
build 1.0.3
charset-normalizer 3.2.0
distro 1.8.0
docutils 0.20.1
editables 0.5
exceptiongroup 1.1.3
gpg 1.21.0
hatchling 1.18.0
idna 3.4
imagesize 1.4.1
importlib-metadata 6.8.0
iniconfig 2.0.0
installer 0.7.0
Jinja2 3.1.2
libcomps 0.1.19
markdown-it-py 3.0.0
MarkupSafe 2.1.3
mdit-py-plugins 0.4.0
mdurl 0.1.2
myst-parser 2.0.0
packaging 23.1
pathspec 0.11.2
pkg 0.0.0
pluggy 1.3.0
Pygments 2.16.1
pyproject_hooks 1.0.0
pytest 7.4.2
pytest-mock 3.11.1
python-dateutil 2.8.2
pytz 2023.3
PyYAML 6.0.1
requests 2.31.0
six 1.16.0
snowballstemmer 2.2.0
Sphinx 7.0.1
sphinx-autodoc-typehints 1.24.0
sphinxcontrib-applehelp 1.0.4
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.3
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.9
tomli 2.0.1
trove-classifiers 2023.9.19
urllib3 1.26.16
wheel 0.41.1
zipp 3.17.0
python3 -m hatch_jupyter_builder.migrate .
on the K3D repo.shared-data
section.hatch-jupyter-builder == 0.6.2
I am not sure if this belongs to this project or another, but is it possible to conditionally run this builder hook? I.e. have a project that is primarily python based, but include python extensions. This issue came up in the request of this issue. I see in the documentation that you can add the dependencies
to it, but would that only be pulled if the jupyter build is enabled?
I have to install this project just to run it once
We could add a [project.scripts]
table, either with a single entrypoint like
[project.scripts]
hatch-jupyter-builder = 'hatch_jupyter_builder.cli:run'
which can be called as hatch-jupyter-builder migrate .
and hatch-jupyter-builder compare-migrated a b [wheel|sdist]
.
Or we could add multiple scripts:
[project.scripts]
hjb-migrate = 'hatch_jupyter_builder.migrate:run'
hjb-compare-migrated = 'hatch_jupyter_builder.compare_migrated:run'
I'm trying to build an example widget using the jupyter-widgets cookiecutter: https://github.com/jupyter-widgets/widget-ts-cookiecutter. Using hatch-jupyter-builder==0.5.3
, pip install .
completes successfully. Under hatch-jupyter-builder==0.6.0
, the build fails.
pip install cookiecutter jupyter lab
cookiecutter https://github.com/jupyter-widgets/widget-ts-cookiecutter
cd myproject
pip install -e .
This fails to build with the following error:
Traceback (most recent call last):
File "/home/pdmurray/.pyenv/versions/mambaforge/envs/myapp/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 177, in prepare_metadata_for_build_editable
hook = backend.prepare_metadata_for_build_editable
AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pdmurray/.pyenv/versions/mambaforge/envs/myapp/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/home/pdmurray/.pyenv/versions/mambaforge/envs/myapp/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/pdmurray/.pyenv/versions/mambaforge/envs/myapp/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 186, in prepare_metadata_for_build_editable
whl_basename = build_hook(metadata_directory, config_settings)
File "/tmp/pip-build-env-rz5poet1/overlay/lib/python3.10/site-packages/hatchling/build.py", line 61, in build_editable
return os.path.basename(next(builder.build(wheel_directory, ['editable'])))
File "/tmp/pip-build-env-rz5poet1/overlay/lib/python3.10/site-packages/hatchling/builders/plugin/interface.py", line 136, in build
build_hook.initialize(version, build_data)
File "/tmp/pip-build-env-rz5poet1/normal/lib/python3.10/site-packages/hatch_jupyter_builder/plugin.py", line 38, in initialize
config = JupyterBuildConfig(**normalize_kwargs(self.config)) # type: ignore[arg-type]
TypeError: JupyterBuildConfig.__init__() got an unexpected keyword argument 'dependencies'
error: subprocess-exited-with-error
I've been playing around trying to get the widget cookiecutter to work for the past few hours. Then a little while ago this error started appearing. I saw that the issue was with hatch_jupyter_builder
, and there's been a new release a few minutes ago, so I tried v0.5.3
and it works.
The build completes successfully.
[~/Desktop/workspace/myproject]⟦myapp⟧$ mamba list
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
anyio 3.6.1 pypi_0 pypi
argon2-cffi 21.3.0 pypi_0 pypi
argon2-cffi-bindings 21.2.0 pypi_0 pypi
asttokens 2.0.8 pypi_0 pypi
attrs 22.1.0 pypi_0 pypi
babel 2.10.3 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
beautifulsoup4 4.11.1 pypi_0 pypi
bleach 5.0.1 pypi_0 pypi
bzip2 1.0.8 h7f98852_4 conda-forge
ca-certificates 2022.6.15 ha878542_0 conda-forge
certifi 2022.6.15 pypi_0 pypi
cffi 1.15.1 pypi_0 pypi
charset-normalizer 2.1.1 pypi_0 pypi
debugpy 1.6.3 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
entrypoints 0.4 pypi_0 pypi
executing 1.0.0 pypi_0 pypi
fastjsonschema 2.16.1 pypi_0 pypi
idna 3.3 pypi_0 pypi
ipykernel 6.15.2 pypi_0 pypi
ipython 8.5.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
ipywidgets 8.0.2 pypi_0 pypi
jedi 0.18.1 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
json5 0.9.10 pypi_0 pypi
jsonschema 4.15.0 pypi_0 pypi
jupyter-client 7.3.5 pypi_0 pypi
jupyter-core 4.11.1 pypi_0 pypi
jupyter-server 1.18.1 pypi_0 pypi
jupyterlab 3.4.6 pypi_0 pypi
jupyterlab-pygments 0.2.2 pypi_0 pypi
jupyterlab-server 2.15.1 pypi_0 pypi
jupyterlab-widgets 3.0.3 pypi_0 pypi
ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-ng 12.1.0 h8d9b700_16 conda-forge
libgomp 12.1.0 h8d9b700_16 conda-forge
libnsl 2.0.0 h7f98852_0 conda-forge
libsqlite 3.39.3 h753d276_0 conda-forge
libuuid 2.32.1 h7f98852_1000 conda-forge
libzlib 1.2.12 h166bdaf_2 conda-forge
lxml 4.9.1 pypi_0 pypi
markupsafe 2.1.1 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
mistune 2.0.4 pypi_0 pypi
myproject 0.1.0.dev0 pypi_0 pypi
nbclassic 0.4.3 pypi_0 pypi
nbclient 0.6.7 pypi_0 pypi
nbconvert 7.0.0 pypi_0 pypi
nbformat 5.4.0 pypi_0 pypi
ncurses 6.3 h27087fc_1 conda-forge
nest-asyncio 1.5.5 pypi_0 pypi
notebook 6.4.12 pypi_0 pypi
notebook-shim 0.1.0 pypi_0 pypi
openssl 3.0.5 h166bdaf_2 conda-forge
packaging 21.3 pypi_0 pypi
pandocfilters 1.5.0 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pip 22.2.2 pyhd8ed1ab_0 conda-forge
prometheus-client 0.14.1 pypi_0 pypi
prompt-toolkit 3.0.31 pypi_0 pypi
psutil 5.9.2 pypi_0 pypi
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
pycparser 2.21 pypi_0 pypi
pygments 2.13.0 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
pyrsistent 0.18.1 pypi_0 pypi
python 3.10.6 ha86cf86_0_cpython conda-forge
python-dateutil 2.8.2 pypi_0 pypi
pytz 2022.2.1 pypi_0 pypi
pyzmq 23.2.1 pypi_0 pypi
readline 8.1.2 h0f457ee_0 conda-forge
requests 2.28.1 pypi_0 pypi
send2trash 1.8.0 pypi_0 pypi
setuptools 65.3.0 pyhd8ed1ab_1 conda-forge
six 1.16.0 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
soupsieve 2.3.2.post1 pypi_0 pypi
stack-data 0.5.0 pypi_0 pypi
terminado 0.15.0 pypi_0 pypi
tinycss2 1.1.1 pypi_0 pypi
tk 8.6.12 h27826a3_0 conda-forge
tornado 6.2 pypi_0 pypi
traitlets 5.3.0 pypi_0 pypi
tzdata 2022c h191b570_0 conda-forge
urllib3 1.26.12 pypi_0 pypi
wcwidth 0.2.5 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
websocket-client 1.4.1 pypi_0 pypi
wheel 0.37.1 pyhd8ed1ab_0 conda-forge
widgetsnbextension 4.0.3 pypi_0 pypi
xz 5.2.6 h166bdaf_0 conda-forge
This is more of a "desired behaviour" thread than a bug report.
To my mind, this build hook should not build the extension for the sdist. Off-hand, I feel that sdists should really contain as little generated code as possible. After all, whoever installs from the sdist will still (at present) run the builder anyway.
What are your thoughts on doing nothing for the sdist, and only running the builder for the wheel?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.