Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for package data #66

Open
nthiery opened this issue Sep 28, 2023 · 1 comment
Open

Support for package data #66

nthiery opened this issue Sep 28, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@nthiery
Copy link

nthiery commented Sep 28, 2023

Description

I have a Python package which includes package data, to be accessed
through importlib.resources. However, within jupyterlite, importlib.resources
fails do find the data.

Reproduce

  1. Clone https://github.com/jupyterlite/xeus-python-demo

  2. Add these dependencies to environment.yml

      - pip
      - pip:
        - "git+https://gitlab.dsi.universite-paris-saclay.fr/nicolas.thiery/Laby.git"
    
  3. Build JupyterLite

    mamba env create --force -f build-environment.yml
    conda activate build-env
    cp README.md content
    jupyter lite build --contents content --output-dir dist
    
  4. Check the log, and notice the copying of the package data when building the wheel:

    creating build/bdist.linux-x86_64/wheel/laby/resources/tiles_png
    copying build/lib/laby/resources/tiles_png/nweb.png -> build/bdist.linux-x86_64/wheel/laby/resources/tiles_png
    ...
    
  5. Browse dist/extensions/@jupyterlite/xeus-python-kernel/static/laby_python-0.0.5-pip.tar.gz

    Expected behavior: the archive contain the package data.
    Got: the package contains only the Python code

  6. Run JupyterLite and from a python kernel run:

    tiles_dir = importlib.resources.files("laby").joinpath("resources", "tiles_png")
    list(tiles_dir.glob("*"))
    

    Expected behavior: a list of files including 'nweb.png`.
    Got: the empty list

Context

  • JupyterLite version: 0.1.2
  • Operating System and version: Ubuntu 22.04
  • Browser and version: Firefox/chromium
@nthiery nthiery added the bug Something isn't working label Sep 28, 2023
@martinRenou
Copy link
Member

martinRenou commented Sep 28, 2023

Thank you for opening an issue. Would you be able to confirm that os.path.exists("/lib/python3.10/site-packages/laby/resources/tiles_png/nweb.png") returns True?

I misread the issue. This will definitely return False if

Expected behavior: the archive contain the package data.
Got: the package contains only the Python code

So this has to do with either the empack filtering logic or the way we add package data for the pip dependencies. I'd bet on the empack filtering logic.

@jtpio jtpio transferred this issue from jupyterlite/xeus-python-kernel Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants