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

PEP440 code in setuptools 8.2.1 is parsing version number incorrectly for package with hyphen in name #307

Closed
bb-migration opened this Issue Dec 19, 2014 · 16 comments

Comments

Projects
None yet
1 participant
@bb-migration

bb-migration commented Dec 19, 2014

Originally reported by: msabramo (Bitbucket: msabramo, GitHub: msabramo)


I created a package called setuptools-markdown (note hyphen in name).

pkg_resources is struggling to parse the version, thinking that markdown is part of the version.

❯ python setup.py egg_info
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.1.dev2)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.1.dev1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.1dev1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.1dev)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py:2443: PEP440Warning: 'setuptools (markdown-0.0dev)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,

@bb-migration

This comment has been minimized.

bb-migration commented Dec 19, 2014

Original comment by msabramo (Bitbucket: msabramo, GitHub: msabramo):


❯ python setup.py egg_info
> /Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py(2436)parsed_version()
-> warnings.warn(
(Pdb) self.project_name
'setuptools'
(Pdb) self.version
'markdown-0.1'
@bb-migration

This comment has been minimized.

bb-migration commented Dec 19, 2014

Original comment by msabramo (Bitbucket: msabramo, GitHub: msabramo):


> /Users/marca/python/virtualenvs/setuptools-markdown/lib/python2.7/site-packages/pkg_resources.py(975)add()
-> if dist not in dists:
(Pdb) dist
setuptools markdown-0.0dev (https://pypi.python.org/packages/source/s/setuptools-markdown/setuptools-markdown-0.0dev.tar.gz#md5=83dbca7acafbd551f3d4643834ad5553)
@bb-migration

This comment has been minimized.

bb-migration commented Dec 19, 2014

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I know there are problems with distutils and setuptools regarding dashes and underscores in distribution names. I believe setuptools will convert an underscore to a dash in some cases, but it may not be allowed to use a dash explicitly in a name (because the dash is used in a filename as the separator between the package name and the version indicator).

Does setuptools-markdown work properly with setuptools < 8?

@bb-migration

This comment has been minimized.

bb-migration commented Dec 20, 2014

Original comment by dstufft (Bitbucket: dstufft, GitHub: dstufft):


I'm pretty sure the problem here is the same problem that caused the foo-1.0 () errors that we added the if version gate on the warning but I can't think of the solution off the top of my head besides turn off warnings by default.

The problem is that setuptools (and distutils, etc) do allow a - in the name of the project. They also allow a - in the version of a project. This means that if you take something like setuptools-markdown-1.0.dev1 there's no good way to determine if that is ("setuptools", "markdown-1.0dev1") or ("setuptools-markdown", "1.0dev1") or ("setuptools-markdown-1.0dev1", ""). If I recall as part of parsing setuptools more or less just iterates over all the possible combinations and tries to pick which one is the best choice. As part of iterating over all the combinations it triggers the PEP440Warning. I believe the only thing that doesn't have this problem is Wheels because they explicitly mandate that a Wheel has to escape a - in the project name or version as _ and it uses - only as a seperator between segments in the filename.

@bb-migration

This comment has been minimized.

bb-migration commented Dec 20, 2014

Original comment by arfrever (Bitbucket: arfrever, GitHub: arfrever):


I suggest treat -${element} as version only if ${element} contains only (dot|hyphen)-separated digits with optional (dev|a|b|rc|post)${optional_digits}. "markdown" would certainly not count as version.

@bb-migration

This comment has been minimized.

bb-migration commented Dec 20, 2014

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I get this same warning with the pytest-runner package. Setuptools 8.x only.

@bb-migration

This comment has been minimized.

bb-migration commented Feb 11, 2015

Original comment by jayvdb (Bitbucket: jayvdb, GitHub: jayvdb):


I am seeing the same problem with Setuptools 12.0.5 (see lines 205-206)
https://travis-ci.org/jayvdb/pywikibot-core/jobs/50130757

@bb-migration

This comment has been minimized.

bb-migration commented Mar 15, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Issue #351 was marked as a duplicate of this issue.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Update EGG_NAME regular expression matcher to allow names to include dashes. Fixes failing test and fixes #307.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Add test capturing failure to parse package names with hyphens. Ref #307

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


So while my test captured one such parsing of a Distribution from a filename, that's not the behavior that's causing the parsing. The test and patch did not address the issue.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Here is the code where the Distributions are generated.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Backed out changeset 6e045b2724d0 and 56d7ea3d42b2. Ref #307.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Disable warning of LegacyVersion in parsed_version. This functionality should be called explicitly at whatever times are appropriate for the warning. Fixes #307.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I believe the only thing that doesn't have this problem is Wheels because they explicitly mandate that a Wheel has to escape a - in the project name or version as _ and it uses - only as a seperator between segments in the filename.

I see now that eggs also do not have this issue and for the same reason.

@bb-migration

This comment has been minimized.

bb-migration commented Mar 20, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Released as 14.3.1.

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