jupyterlab/extension-cookiecutter-ts

The labextension is included twice in the Python wheel

martinRenou opened this issue · 9 comments

Description

With the packaging approach taken in this repo, the wheel will contain twice the labextension:

  • once installed in /lib/python*.*/python_pkg_name/labextension/
  • once installed in /share/jupyter/labextensions/

I suppose it was done this way so that the Python module can find the version looking at the package.json of the labextension?

Expected behavior

Include the labextension only once, not installing the labextension under site-packages as it should not be needed there.

This is gonna be tricky because it is the consequence of integrating the JS assets to allow installation from source distribution without the need to transpile those Javascript assets.

Does the linked PR keeps the JS assets in the resulting source distribution?

Yes it keeps them in the source distribution, under share/jupyter/labextensions/ext_name at the root of the source, which is in a way the representation of what will be installed in the prefix.

@fcollonval I suppose the initial reason for installing the labextension under /lib/python*.*/python_pkg_name/labextension/ as package data, was to have access to the package.json file in order to get the package version https://github.com/jupyterlab/extension-cookiecutter-ts/blob/3.0/%7B%7Bcookiecutter.python_name%7D%7D/%7B%7Bcookiecutter.python_name%7D%7D/_version.py#L9.

This is avoided e.g. in bqplot by either finding the package.json locally if it's a dev install or by finding it in the prefix path under share: https://github.com/bqplot/bqplot/blob/master/bqplot/__init__.py#L73-L88

If that's an approach you agree with, I can come up with a PR.

@martinRenou I'm reopening as I assume the close action comes from automatic link.

Thanks! I didn't know automatic closing worked between repos, now I know :P

jtpio commented

@martinRenou do you know if that's still the case after the switch to hatch (#222)?

Yes, this is still the case with hatch. +1 for making the cookiecutter produce smaller wheels.

Indeed it's still the case after the migration to hatch.

Sadly, for some packages where I fixed this duplication (bqplot etc), this issue came back with the migration to hatch.

To solves this with hatch, we can keep the current logic (of placing the JS assets in the Python packaging). But exclude that folder from the wheel (only) using: https://hatch.pypa.io/latest/build/#configuration