summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-10-22 12:44:53 -0400
committerJason R. Coombs <jaraco@jaraco.com>2021-10-22 12:44:53 -0400
commit6fc5d3099898fc3d06bcf72f1f6607d02124d60f (patch)
treec3d88a729e9e8f7d89ab6653582df9a6eb55bd88
parenta9d3576584cd9a91734dae6473ab6c3253f09f64 (diff)
downloadpython-setuptools-git-6fc5d3099898fc3d06bcf72f1f6607d02124d60f.tar.gz
Update test_egg_fragment to include a name with a dash in it. Expand on interpret_distro_name to be a tiny bit smarter about inferring the pivot separating name and version.
-rw-r--r--setuptools/package_index.py9
-rw-r--r--setuptools/tests/test_packageindex.py2
2 files changed, 9 insertions, 2 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 1300b406..bef2ef81 100644
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -165,7 +165,14 @@ def interpret_distro_name(
# it is a bdist_dumb, not an sdist -- bail out
return
- p = len(parts) - 1
+ # find the pivot (p) that splits the name from the version.
+ # infer the version as the first item that has a digit.
+ for p in range(len(parts)):
+ if parts[p][:1].isdigit():
+ break
+ else:
+ p = len(parts)
+
yield Distribution(
location, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]),
py_version=py_version, precedence=precedence,
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 8e9435ef..5f09e1bd 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -189,7 +189,7 @@ class TestPackageIndex:
for locs in local]
for v, vc in versions:
dists = list(setuptools.package_index.distros_for_url(
- 'http://example.com/example.zip#egg=example-' + v))
+ 'http://example.com/example-foo.zip#egg=example-foo-' + v))
assert dists[0].version == ''
assert dists[1].version == vc