Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Add support for pip dependencies #102

Merged
merged 12 commits into from
Jul 24, 2023
Merged

Conversation

martinRenou
Copy link
Member

@martinRenou martinRenou commented Dec 23, 2022

Would fix #100 and probably fix #48

This is very much experimental for now.

Pip is running with the --no-deps option, meaning that the user would need to install the package dependencies from conda-forge/emscripten-forge/PyPI themselves.

Pip is not made for installing packages in another environment (it is supposed to install packages for the Python version it uses, nothing else), so we have to workaround this by doing some shenanigans to make it work. The --no-deps option is one of those workarounds.

I don't think we should support reading some requirements.txt file for now, at least not before pip packages are more correctly supported, if they ever are.

@martinRenou
Copy link
Member Author

This does not work yet. The installed pip packages get filtered out by empack. We need to find a somewhat clean way for empack to not do this.

@martinRenou
Copy link
Member Author

Building with emscripten-forge/empack#65

Running pip install with --no-deps may be required, because it seems to not look properly into what's already installed in the prefix we install packages.

@martinRenou
Copy link
Member Author

martinRenou commented Jul 24, 2023

Local testing is working. Let's release empack.

Tried with pip-installed ipycanvas that ships a lab extension:

[LiteBuildApp] WARNING | 
            Installing pip dependencies. This is very much experimental so use this feature at your own risks.
            Note that you can only install pure-python packages.
            pip is being run with the --no-deps option to not pull undesired system-specific dependencies, so please
            install your package dependencies from emscripten-forge or conda-forge.
            
Using pip 23.2 from /home/martinrenou/micromamba/envs/xeus-python-kernel/lib/python3.11/site-packages/pip (python 3.11)
Collecting ipycanvas
  Using cached ipycanvas-0.13.1-py2.py3-none-any.whl (255 kB)
Installing collected packages: ipycanvas
Successfully installed ipycanvas-0.13.1
jupyterlite-xeus-python:xeus:copy:ext:ipycanvas
.  post_build:jupyterlite-xeus-python:xeus:copy:ext:ipycanvas

@martinRenou
Copy link
Member Author

Working great on RTD

Screenshot from 2023-07-24 13-42-02

@martinRenou martinRenou requested a review from jtpio July 24, 2023 11:43
@martinRenou martinRenou marked this pull request as ready for review July 24, 2023 11:43
@jtpio
Copy link
Member

jtpio commented Jul 24, 2023

Maybe we can also update the docs to remove this note?

image

And add a small yaml snippet to show how to install packages from PyPI when they are not available on conda forge?

@martinRenou
Copy link
Member Author

Yes!

@martinRenou martinRenou merged commit c456fbe into jupyterlite:main Jul 24, 2023
@martinRenou martinRenou deleted the pip_deps branch July 24, 2023 12:28
@martinRenou
Copy link
Member Author

Thanks for the review!


`xeus-python` provides a way to install packages with pip.

There are a couple of limitations that you should be aware of:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it also support installing via a requirements file?

- pip:
  - -r requirements.txt

Since this is also a common use case. If it's not supported we could add it to the list of limitations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know of this case. We should add it indeed then!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example generated via pip freeze.

This would also fix #121 if we document the workflow.

@martinRenou
Copy link
Member Author

Confirming in ipycanvas that installing a local Python package works nicely:

See jupyter-widgets-contrib/ipycanvas#338

name: ipycanvas
channels:
  - https://repo.mamba.pm/emscripten-forge
  - https://repo.mamba.pm/conda-forge
dependencies:
  - pillow
  - numpy
  - ipywidgets
  - pip:
    - ..

Screenshot from 2023-07-25 09-52-17

@martinRenou
Copy link
Member Author

@nthiery You can have a try with this!

The documentation for it is here https://xeus-python-kernel.readthedocs.io/en/latest/configuration.html#pip-packages

For example it is being used here jupyter-widgets-contrib/ipycanvas#338

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants