Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.15.4
=======

* fix issue #164: iterate all found entry points to avoid erros when pip remakes egg-info

v1.15.3
=======

Expand Down
8 changes: 7 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ buildPythonPackage {
name = "setuptools_scm";
src = ./.;
version = "git";
buildInputs = [setuptools pip pytest pkgs.git pkgs.mercurial];
buildInputs = [
setuptools
pip
pytest
pkgs.git
pkgs.mercurial
];
}

9 changes: 5 additions & 4 deletions setuptools_scm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .utils import trace
from .version import format_version, meta, ScmVersion
from .discover import find_matching_entrypoint
from .discover import iter_matching_entrypoints

PRETEND_KEY = 'SETUPTOOLS_SCM_PRETEND_VERSION'

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


def _version_from_entrypoint(root, entrypoint):
ep = find_matching_entrypoint(root, entrypoint)
if ep:
return ep.load()(root)
for ep in iter_matching_entrypoints(root, entrypoint):
version = ep.load()(root)
if version:
return version


def dump_version(root, version, write_to, template=None):
Expand Down
4 changes: 2 additions & 2 deletions setuptools_scm/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from .utils import trace


def find_matching_entrypoint(path, entrypoint):
def iter_matching_entrypoints(path, entrypoint):
trace('looking for ep', entrypoint, path)
for ep in iter_entry_points(entrypoint):
if os.path.exists(os.path.join(path, ep.name)):
if os.path.isabs(ep.name):
trace('ignoring bad ep', ep)
trace('found ep', ep)
return ep
yield ep
10 changes: 6 additions & 4 deletions setuptools_scm/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .version import _warn_if_setuptools_outdated
from .utils import do
from .discover import find_matching_entrypoint
from .discover import iter_matching_entrypoints
from . import get_version


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

Expand All @@ -25,7 +26,8 @@ def find_files(path='.'):
if not path:
path = '.'
abs = os.path.abspath(path)
ep = find_matching_entrypoint(abs, 'setuptools_scm.files_command')
ep = next(iter_matching_entrypoints(
abs, 'setuptools_scm.files_command'), None)
if ep:
command = ep.load()
try:
Expand Down
10 changes: 10 additions & 0 deletions testing/test_regressions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import subprocess

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


@pytest.mark.issue(164)
def test_pip_download(tmpdir, monkeypatch):
monkeypatch.chdir(tmpdir)
subprocess.check_call([
sys.executable, '-c',
'import pip;pip.main()', 'download', 'lz4==0.9.0',
])


def test_use_scm_version_callable(tmpdir, monkeypatch):
"""use of callable as use_scm_version argument"""
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
Expand Down