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

Compatible release clause behaviour differs from PEP440 for versions with prerelease #100

Closed
timdiels opened this issue Mar 13, 2017 · 2 comments · Fixed by #366
Closed

Comments

@timdiels
Copy link

PEP440 gives the example that ~= 1.4.5a4 should be equivalent to >= 1.4.5a4, == 1.4.*, however:

>>> from packaging.specifiers import SpecifierSet
>>> '1.4.6' in SpecifierSet('~=1.4.5a4', prereleases=True)  # incorrect
False
>>> '1.4.6' in SpecifierSet('>=1.4.5a4, ==1.4.*', prereleases=True)  # correct
True

It appears there has been a misinterpretation, treating ~=1.4.5a4 as >= 1.4.5a4, == 1.4.5.*. Compare this to PEP440: "If a pre-release, post-release or developmental release is named in a compatible release clause as V.N.suffix , then the suffix is ignored when determining the required prefix match".

My environment:

(venv) $ pip freeze
appdirs==1.4.2
attrs==16.3.0
chicken-turtle-util==4.0.1
lxml==3.7.3
numpy==1.12.0
packaging==16.8
patool==1.12
pkginfo==1.4.1
py==1.4.32
pypandoc==1.3.3
pyparsing==2.2.0
pytest==3.0.6
pytest-capturelog==0.7
requests==2.13.0
six==1.10.0
(venv) $ python --version
Python 3.5.2
@di
Copy link
Member

di commented Dec 2, 2020

It seems like that wording in the PEP 440 is indeed at odds with the actual implementation, which explicitly treats prereleases differently:

# We want everything but the last item in the version, but we want to
# ignore post and dev releases and we want to treat the pre-release as
# it's own separate segment.
prefix = ".".join(
list(
itertools.takewhile(
lambda x: (not x.startswith("post") and not x.startswith("dev")),
_version_split(spec),
)
)[:-1]
)

Currently prereleases are not ignored, but treated as it's own segment, so you get this instead:

~=1.4.5a4 as
>=1.4.5a4, ==1.4.5.*

Given that @dstufft was the one to originally implement it like this, perhaps he has an idea about why?

@jiasli
Copy link

jiasli commented Dec 18, 2020

This bug becomes more outstanding as pip's new resolver is more strict and fails due to incompatible dependencies.

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

Successfully merging a pull request may close this issue.

4 participants