Skip to content

Commit 34125b8

Browse files
Merge pull request #165 from RonnyPfannschmidt/fix-164
Fix issue #164
2 parents a3bc80d + a9aa2f9 commit 34125b8

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v1.15.4
2+
=======
3+
4+
* fix issue #164: iterate all found entry points to avoid erros when pip remakes egg-info
5+
16
v1.15.3
27
=======
38

default.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ buildPythonPackage {
44
name = "setuptools_scm";
55
src = ./.;
66
version = "git";
7-
buildInputs = [setuptools pip pytest pkgs.git pkgs.mercurial];
7+
buildInputs = [
8+
setuptools
9+
pip
10+
pytest
11+
pkgs.git
12+
pkgs.mercurial
13+
];
814
}
915

setuptools_scm/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .utils import trace
1010
from .version import format_version, meta, ScmVersion
11-
from .discover import find_matching_entrypoint
11+
from .discover import iter_matching_entrypoints
1212

1313
PRETEND_KEY = 'SETUPTOOLS_SCM_PRETEND_VERSION'
1414

@@ -32,9 +32,10 @@ def version_from_scm(root):
3232

3333

3434
def _version_from_entrypoint(root, entrypoint):
35-
ep = find_matching_entrypoint(root, entrypoint)
36-
if ep:
37-
return ep.load()(root)
35+
for ep in iter_matching_entrypoints(root, entrypoint):
36+
version = ep.load()(root)
37+
if version:
38+
return version
3839

3940

4041
def dump_version(root, version, write_to, template=None):

setuptools_scm/discover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from .utils import trace
44

55

6-
def find_matching_entrypoint(path, entrypoint):
6+
def iter_matching_entrypoints(path, entrypoint):
77
trace('looking for ep', entrypoint, path)
88
for ep in iter_entry_points(entrypoint):
99
if os.path.exists(os.path.join(path, ep.name)):
1010
if os.path.isabs(ep.name):
1111
trace('ignoring bad ep', ep)
1212
trace('found ep', ep)
13-
return ep
13+
yield ep

setuptools_scm/integration.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .version import _warn_if_setuptools_outdated
44
from .utils import do
5-
from .discover import find_matching_entrypoint
5+
from .discover import iter_matching_entrypoints
66
from . import get_version
77

88

@@ -15,8 +15,9 @@ def version_keyword(dist, keyword, value):
1515
if getattr(value, '__call__', None):
1616
value = value()
1717
# this piece of code is a hack to counter the mistake in root finding
18-
ep = find_matching_entrypoint('.', 'setuptools_scm.parse_scm_fallback')
19-
if ep is not None:
18+
matching_fallbacks = iter_matching_entrypoints(
19+
'.', 'setuptools_scm.parse_scm_fallback')
20+
if any(matching_fallbacks):
2021
value.pop('root', None)
2122
dist.metadata.version = get_version(**value)
2223

@@ -25,7 +26,8 @@ def find_files(path='.'):
2526
if not path:
2627
path = '.'
2728
abs = os.path.abspath(path)
28-
ep = find_matching_entrypoint(abs, 'setuptools_scm.files_command')
29+
ep = next(iter_matching_entrypoints(
30+
abs, 'setuptools_scm.files_command'), None)
2931
if ep:
3032
command = ep.load()
3133
try:

testing/test_regressions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import subprocess
23

34
from setuptools_scm import get_version
45
from setuptools_scm.git import parse
@@ -48,6 +49,15 @@ def test_pip_egg_info(tmpdir, monkeypatch):
4849
assert get_version(root=p.strpath) == '1.0'
4950

5051

52+
@pytest.mark.issue(164)
53+
def test_pip_download(tmpdir, monkeypatch):
54+
monkeypatch.chdir(tmpdir)
55+
subprocess.check_call([
56+
sys.executable, '-c',
57+
'import pip;pip.main()', 'download', 'lz4==0.9.0',
58+
])
59+
60+
5161
def test_use_scm_version_callable(tmpdir, monkeypatch):
5262
"""use of callable as use_scm_version argument"""
5363
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")

0 commit comments

Comments
 (0)