extension-cookiecutter-ts icon indicating copy to clipboard operation
extension-cookiecutter-ts copied to clipboard

The labextension is included twice in the Python wheel

Open martinRenou opened this issue 3 years ago • 6 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.

martinRenou avatar May 20 '22 14:05 martinRenou

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?

fcollonval avatar May 20 '22 18:05 fcollonval

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.

martinRenou avatar May 20 '22 18:05 martinRenou

@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 avatar May 23 '22 06:05 martinRenou

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

fcollonval avatar May 23 '22 12:05 fcollonval

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

martinRenou avatar May 23 '22 12:05 martinRenou

@martinRenou do you know if that's still the case after the switch to hatch (https://github.com/jupyterlab/extension-cookiecutter-ts/pull/222)?

jtpio avatar Oct 04 '22 08:10 jtpio

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

krassowski avatar Nov 08 '22 04:11 krassowski

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.

martinRenou avatar Nov 09 '22 08:11 martinRenou

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

fcollonval avatar Nov 09 '22 09:11 fcollonval