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

pre-relseases installed when mentioned directly, not when dependencies. #162

Open
Carreau opened this issue Nov 27, 2024 · 1 comment
Open

Comments

@Carreau
Copy link
Contributor

Carreau commented Nov 27, 2024

found when working on #159, in particular #159 (comment)

Tracked down to:

In [5]: from packaging.requirements import Requirement
   ...: from packaging.version import Version
   ...: req_numpy_with_ver = Requirement('numpy<3,>=1.23')
   ...: req_numpy_no_ver = Requirement('numpy')
   ...:
   ...: print(list(req_numpy_with_ver.specifier.filter([Version('2.2.0.dev')])))
   ...: print(list(req_numpy_with_ver.specifier.filter([Version('2.2.0.dev')], prereleases=True)))
   ...:
   ...: print(list(req_numpy_no_ver.specifier.filter([Version('2.2.0.dev')])))
   ...: print(list(req_numpy_no_ver.specifier.filter([Version('2.2.0.dev')], prereleases=True)))
   ...:
   ...:
[]                          # if a dependency: 
[<Version('2.2.0.dev0')>]
[<Version('2.2.0.dev0')>]   # trigger this is install direct
[<Version('2.2.0.dev0')>]

In [7]: packaging.__version__
Out[7]: '24.1'

This also lead to weird things:

>>> await micropip.install('numpy<3', index_urls=['https://cors.carreau.workers.dev/scientific-python-nightly-wheels/simple'])
# ValueError: Can't find a pure Python 3 wheel for 'numpy<3'.

but (note the lack of <3)

>>> await micropip.install('numpy', index_urls=['https://cors.carreau.workers.dev/scientific-python-nightly-wheels/simple'])
# Successfully installed numpy-2.3.0.dev0

I don't know if it's a packaging bug, or an incorrect usage of packaging; so I'm opening the issue here.

@Carreau
Copy link
Contributor Author

Carreau commented Nov 28, 2024

Ok, this is because the filter operation of packaging is not distributive:

In [29]: list(SpecifierSet('').filter(['1.0','2.2.0.dev']))
Out[29]: ['1.0']

In [30]: list(SpecifierSet('').filter(['2.2.0.dev']))
Out[30]: ['2.2.0.dev']

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

1 participant