-
Notifications
You must be signed in to change notification settings - Fork 253
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
Why does the filter
method of SpecifierSet
with a single specifier behave differently to Specifier
?
#856
Comments
I think maybe it's related so I won't open a new issue but, I have the following issue: 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)))
...:
...:
[]
[<Version('2.2.0.dev0')>]
[<Version('2.2.0.dev0')>]
[<Version('2.2.0.dev0')>]
In [7]: packaging.__version__
Out[7]: '24.1' I don't understand why "just numpy" assumes 2.2.0.dev0 is ok, but if I pin to Sorry I'm just starting to dig into packaging; so there might be a smaller minimum example. |
I guess this can be reduced to
Which seem to be the spec, but this means Which is quite problematic as it is generally understood that filter is distributif, and |
Packaging maintainers, I'm trying to understand if this is a bug or a design choice, if it's a bug I'm happy to work on this, if it's a design choice then I think I need to do some work on pip side to avoid
Yes, due to pre-releases Python packaging version specifiers generally do not conform to "normal" mathematics, some recent discussion here: https://discuss.python.org/t/proposal-intersect-and-disjoint-operations-for-python-version-specifiers/71888. I'm hoping that discussion will lead to a strong spec on this, as currently it's at best confusing |
Here are two cases where I don't understand why
SpecifierSet
andSpecifier
behave differently.One where only a pre-release is available out of all versions, according to the spec I would expect the pre-release to be available:
Two, where there is a pre-release and non-prerelease but only the pre-release matches the specifier requirements, again according to the spec I would expect the pre-release to be available:
Because pip heavily uses
SpecifierSet
(I think because theSpecifier
object is newer) it means pip is often not following the spec as expected.The text was updated successfully, but these errors were encountered: