Skip to content

<1dev is not a valid matcher for Python package versions in setup.py! #2151

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

Closed
con-f-use opened this issue Jun 6, 2023 · 1 comment · Fixed by #2152 or #2150
Closed

<1dev is not a valid matcher for Python package versions in setup.py! #2151

con-f-use opened this issue Jun 6, 2023 · 1 comment · Fixed by #2152 or #2150

Comments

@con-f-use
Copy link
Contributor

con-f-use commented Jun 6, 2023

On the current master branch, you have this matcher for an install_requires package version in setup.py:

install_requires = [
    "httplib2>=0.15.0,<1dev",

The <1dev part is not a valid version specifier (edit: it is valid, just doesn't parse correctly with distlib) in the sense of PEP 440 and causes problems with a number of packing tools, as seen here:

$ python -c 'from distlib.version import NormalizedMatcher; NormalizedMatcher("httplib2>=0.15.0,<1dev")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jan/.local/share/virtualenvs/master_clean-V3vlFZeD/lib/python3.7/site-packages/distlib/version.py", line 125, in __init__
    vn, prefix = self.version_class(s), False
  File "/home/jan/.local/share/virtualenvs/master_clean-V3vlFZeD/lib/python3.7/site-packages/distlib/version.py", line 33, in __init__
    self._parts = parts = self.parse(s)
  File "/home/jan/.local/share/virtualenvs/master_clean-V3vlFZeD/lib/python3.7/site-packages/distlib/version.py", line 267, in parse
    result = _normalized_key(s)
  File "/home/jan/.local/share/virtualenvs/master_clean-V3vlFZeD/lib/python3.7/site-packages/distlib/version.py", line 188, in _pep_440_key
    raise UnsupportedVersionError('Not a valid version: %s' % s)
distlib.version.UnsupportedVersionError: Not a valid version: 1dev

This is just speculation, but it looks like it was either faultily auto-generated by some tool, is an incomplete copy & paste or you meant <1.dev0. However, development versions are not typically considered by tooling and it's considered bad practice to but an upper bound on python dependencies for no good reason. This should be corrected and ideally the artifact files of the effected versions fixed and re-uploaded on pypi.org.

@con-f-use
Copy link
Contributor Author

Discussion in: googleapis/python-api-core#504

gcf-merge-on-green bot pushed a commit that referenced this issue Jun 6, 2023
`httplib2<1dev` is ~not~ a valid version matcher (edit: it is valid, just doesn't parse with distlib) in the sense of [PEP 440](https://peps.python.org/pep-0440/).

> The canonical public version identifiers MUST comply with the following scheme:
> `[N!]N(.N)*[{a|b|rc}N][.postN][.devN]`

It is also considered bad practice to have an upper bound on package versions and installers like pip do not consider development versions in any case (unless explicitly told to).

Fixes #2151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant