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

Legacy versions aren't in SpecifierSets if the specifier is PEP 440-compatible #74

Closed
jimporter opened this issue Apr 28, 2016 · 2 comments

Comments

@jimporter
Copy link

Suppose you have a version and a specifier, both as strings. The version is not PEP 440-compatible, but the specifier is. Creating version/specifier objects for each results in the version never meeting specifier:

>>> from packaging import version, specifiers
>>> v = version.parse('1.2.3.goofy')
>>> v
<LegacyVersion('1.2.3.goofy')>
>>> spec = specifiers.SpecifierSet('>=1.2')
>>> spec
<SpecifierSet('>=1.2')>
>>> v in spec
False

Presumably, this is because LegacyVersions "will always sort as less than a Version instance."

While some people can just switch to PEP 440-compatible versions, not everyone can. In particular, I'm using this to parse non-Python versions for some tools. I could write my own code for this, but since I already need the packaging package for other stuff, I figured I should just use what already exists.

For my particular issue, I can think of the following solutions:

  1. Write a new version parsing package that doesn't try to enforce PEP 440.
  2. Add a legacy=False argument to SpecifierSet that will force all the specifiers it creates to be LegacySpecifiers. That way, if you know you need to handle legacy versions, you can enable it.
  3. Figure out a way to make Versions and LegacyVersions more compatible so that LegacyVersions don't always count as older.

Thoughts?

@dstufft
Copy link
Member

dstufft commented May 2, 2016

I think this seems like a reasonable idea, although I think I would call it LegacySpecifierSet because I think we'd also want to disable the specialized pre-release handling (since that matches the legacy behavior better).

jimporter pushed a commit to jimporter/packaging that referenced this issue Jan 25, 2017
jimporter pushed a commit to jimporter/packaging that referenced this issue Jan 25, 2017
jimporter pushed a commit to jimporter/packaging that referenced this issue Nov 1, 2017
jimporter added a commit to jimporter/packaging that referenced this issue Dec 23, 2019
jimporter added a commit to jimporter/packaging that referenced this issue Dec 23, 2019
jimporter added a commit to jimporter/packaging that referenced this issue Dec 23, 2019
jimporter added a commit to jimporter/packaging that referenced this issue Jul 10, 2020
jimporter added a commit to jimporter/packaging that referenced this issue Jul 10, 2020
@di
Copy link
Member

di commented Oct 20, 2020

Closing this as we've deprecated LegacyVersion/LegacySpecifier entirely in #342.

@di di closed this as completed Oct 20, 2020
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