diff options
author | Chih-Hsuan Yen <yan12125@gmail.com> | 2020-12-25 14:45:43 +0800 |
---|---|---|
committer | Chih-Hsuan Yen <yan12125@gmail.com> | 2020-12-25 14:56:16 +0800 |
commit | f7e70d0fbf7488198026631b435b3e7faaf3dab2 (patch) | |
tree | 02d36ae597dbb0d4aa6a7b2c4999c97590f58913 | |
parent | 731e1e6c5c7bc73519922847d116ed9ed6833f3b (diff) | |
download | python-setuptools-git-f7e70d0fbf7488198026631b435b3e7faaf3dab2.tar.gz |
package_index: don't create dists with non-PEP440 versions
-rw-r--r-- | setuptools/package_index.py | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 3979b131..bc0ba7a6 100644 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -152,35 +152,24 @@ def interpret_distro_name( location, basename, metadata, py_version=None, precedence=SOURCE_DIST, platform=None ): - """Generate alternative interpretations of a source distro name + """Generate the interpretation of a source distro name Note: if `location` is a filesystem filename, you should call ``pkg_resources.normalize_path()`` on it before passing it to this routine! """ - # Generate alternative interpretations of a source distro name - # Because some packages are ambiguous as to name/versions split - # e.g. "adns-python-1.1.0", "egenix-mx-commercial", etc. - # So, we generate each possible interepretation (e.g. "adns, python-1.1.0" - # "adns-python, 1.1.0", and "adns-python-1.1.0, no version"). In practice, - # the spurious interpretations should be ignored, because in the event - # there's also an "adns" package, the spurious "python-1.1.0" version will - # compare lower than any numeric version number, and is therefore unlikely - # to match a request for it. It's still a potential problem, though, and - # in the long run PyPI and the distutils should go for "safe" names and - # versions in distribution archive names (sdist and bdist). parts = basename.split('-') if not py_version and any(re.match(r'py\d\.\d$', p) for p in parts[2:]): # it is a bdist_dumb, not an sdist -- bail out return - for p in range(1, len(parts) + 1): - yield Distribution( - location, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]), - py_version=py_version, precedence=precedence, - platform=platform - ) + p = len(parts) - 1 + yield Distribution( + location, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]), + py_version=py_version, precedence=precedence, + platform=platform + ) # From Python 2.7 docs |