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

Optional dependencies can not be combined with .whl URIs #205

Open
chrysn opened this issue Feb 8, 2025 · 4 comments
Open

Optional dependencies can not be combined with .whl URIs #205

chrysn opened this issue Feb 8, 2025 · 4 comments

Comments

@chrysn
Copy link

chrysn commented Feb 8, 2025

To ease testing of unreleased versions, I'm publishing a wheel of any main branch build of my project aiocoap, so users can:

>>> import micropip
>>> await micropip.install("https://raw.codeberg.page/aiocoap/aiocoap/@pages/dist/aiocoap-0.4.12.post0-py3-none-any.whl")

Frequently, users need to install dependencies, so my recommendation outside of development is that they do

>>> import micropip
>>> await micropip.install("aiocoap[prettyprint,oscore]")

However, those can't be combined:

>>> import micropip
>>> await micropip.install("https://raw.codeberg.page/aiocoap/aiocoap/@pages/dist/aiocoap-0.4.12.post0-py3-none-any.whl[prettyprint]")
Traceback (most recent call last):
[...]
packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after name and no valid version specifier)
    https://raw.codeberg.page/aiocoap/aiocoap/@pages/dist/aiocoap-0.4.12.post0-py3-none-any.whl[prettyprint]
         ^

(tested on https://pyodide.org/en/latest/console.html)

As far as I understand, this is a shortcoming of micropip, which is not present in pip (can't compare directly because AIU pip doesn't do wheels from URIs, but pip install 'dist/aiocoap-0.4.12.post0-py3-none-any.whl[oscore]' works).

Is this something that might be added, or is there a known workaround?

@hoodmane
Copy link
Member

hoodmane commented Feb 9, 2025

It seems to me like a reasonable feature request, particularly since pip implements an analogous feature. It is a bit horrible to write http://some-url.com/dist-name_plat.whl[extras] but it's better than not having a way to do it at all.

I can't say what workarounds people use maybe @agriyakhetarpal might know.

@ryanking13
Copy link
Member

ryanking13 commented Feb 11, 2025

Maybe we can allow putting extra suffix for emfs:// or file:// protocols only? Then people might be able to download the package first, and install it from the file system.

@chrysn
Copy link
Author

chrysn commented Feb 11, 2025

The interaction of those brackets with URIs is a bit odd in general -- and unlike pip, we're in an environment where explicit Python syntax is an option. So if combining this turns out to be problematic, it may be an option to introduce await micropip.install("https://…/my-version.whl", ["feature1", "feature2"]).

The micropip documentation also lists a syntax await micropip.install("snowballstemmer @ https://.../snowballstemmer.*.whl"), which might lend itself to trying out await micropip.install("snowballstemmer[all] @ https://.../snowballstemmer.*.whl"), but the latest pyodide version didn't seem to support that.

@ryanking13
Copy link
Member

The micropip documentation also lists a syntax await micropip.install("snowballstemmer @ https://.../snowballstemmer.*.whl")

Huh, I think that we never supported this syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants