Commit 51562785 authored by Jason R. Coombs's avatar Jason R. Coombs

Revert "Merge pull request #2533 from pypa/fix/2529"

This reverts commit ef457b2e, reversing
changes made to d2b1f7eb.
parent dc051ceb
...@@ -131,12 +131,10 @@ class InfoCommon: ...@@ -131,12 +131,10 @@ class InfoCommon:
egg_info may be called more than once for a distribution, egg_info may be called more than once for a distribution,
in which case the version string already contains all tags. in which case the version string already contains all tags.
""" """
# Remove the tags if they exist. The tags maybe have been normalized return (
# (e.g. turning .dev into .dev0) so we can't just compare strings version if self.vtags and version.endswith(self.vtags)
base_version = parse_version(version).base_version else version + self.vtags
)
# Add the tags
return base_version + self.vtags
def tags(self): def tags(self):
version = '' version = ''
......
...@@ -6,7 +6,6 @@ import re ...@@ -6,7 +6,6 @@ import re
import stat import stat
import time import time
from setuptools.build_meta import prepare_metadata_for_build_wheel
from setuptools.command.egg_info import ( from setuptools.command.egg_info import (
egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision, egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision,
) )
...@@ -20,26 +19,6 @@ from .textwrap import DALS ...@@ -20,26 +19,6 @@ from .textwrap import DALS
from . import contexts from . import contexts
def _run_egg_info_command(tmpdir_cwd, env, cmd=None, output=None):
environ = os.environ.copy().update(
HOME=env.paths['home'],
)
if cmd is None:
cmd = [
'egg_info',
]
code, data = environment.run_setup_py(
cmd=cmd,
pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
data_stream=1,
env=environ,
)
assert not code, data
if output:
assert output in data
class Environment(str): class Environment(str):
pass pass
...@@ -153,7 +132,7 @@ class TestEggInfo: ...@@ -153,7 +132,7 @@ class TestEggInfo:
def test_expected_files_produced(self, tmpdir_cwd, env): def test_expected_files_produced(self, tmpdir_cwd, env):
self._create_project() self._create_project()
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
actual = os.listdir('foo.egg-info') actual = os.listdir('foo.egg-info')
expected = [ expected = [
...@@ -187,7 +166,7 @@ class TestEggInfo: ...@@ -187,7 +166,7 @@ class TestEggInfo:
# currently configured to use a subprocess, the actual traceback # currently configured to use a subprocess, the actual traceback
# object is lost and we need to parse it from stderr # object is lost and we need to parse it from stderr
with pytest.raises(AssertionError) as exc: with pytest.raises(AssertionError) as exc:
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
# Hopefully this is not too fragile: the only argument to the # Hopefully this is not too fragile: the only argument to the
# assertion error should be a traceback, ending with: # assertion error should be a traceback, ending with:
...@@ -201,13 +180,13 @@ class TestEggInfo: ...@@ -201,13 +180,13 @@ class TestEggInfo:
"""Ensure timestamps are updated when the command is re-run.""" """Ensure timestamps are updated when the command is re-run."""
self._create_project() self._create_project()
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
timestamp_a = os.path.getmtime('foo.egg-info') timestamp_a = os.path.getmtime('foo.egg-info')
# arbitrary sleep just to handle *really* fast systems # arbitrary sleep just to handle *really* fast systems
time.sleep(.001) time.sleep(.001)
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
timestamp_b = os.path.getmtime('foo.egg-info') timestamp_b = os.path.getmtime('foo.egg-info')
assert timestamp_a != timestamp_b assert timestamp_a != timestamp_b
...@@ -222,7 +201,7 @@ class TestEggInfo: ...@@ -222,7 +201,7 @@ class TestEggInfo:
'usage.rst': "Run 'hi'", 'usage.rst': "Run 'hi'",
} }
}) })
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
egg_info_dir = os.path.join('.', 'foo.egg-info') egg_info_dir = os.path.join('.', 'foo.egg-info')
sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt') sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt')
with open(sources_txt) as f: with open(sources_txt) as f:
...@@ -462,7 +441,7 @@ class TestEggInfo: ...@@ -462,7 +441,7 @@ class TestEggInfo:
self, tmpdir_cwd, env, requires, use_setup_cfg, self, tmpdir_cwd, env, requires, use_setup_cfg,
expected_requires, install_cmd_kwargs): expected_requires, install_cmd_kwargs):
self._setup_script_with_requires(requires, use_setup_cfg) self._setup_script_with_requires(requires, use_setup_cfg)
_run_egg_info_command(tmpdir_cwd, env, **install_cmd_kwargs) self._run_egg_info_command(tmpdir_cwd, env, **install_cmd_kwargs)
egg_info_dir = os.path.join('.', 'foo.egg-info') egg_info_dir = os.path.join('.', 'foo.egg-info')
requires_txt = os.path.join(egg_info_dir, 'requires.txt') requires_txt = os.path.join(egg_info_dir, 'requires.txt')
if os.path.exists(requires_txt): if os.path.exists(requires_txt):
...@@ -482,14 +461,14 @@ class TestEggInfo: ...@@ -482,14 +461,14 @@ class TestEggInfo:
req = 'install_requires={"fake-factory==0.5.2", "pytz"}' req = 'install_requires={"fake-factory==0.5.2", "pytz"}'
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env): def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env):
tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},'
req = tmpl.format(marker=self.invalid_marker) req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env): def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env):
...@@ -497,7 +476,7 @@ class TestEggInfo: ...@@ -497,7 +476,7 @@ class TestEggInfo:
req = tmpl.format(marker=self.invalid_marker) req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
_run_egg_info_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_provides_extra(self, tmpdir_cwd, env): def test_provides_extra(self, tmpdir_cwd, env):
...@@ -886,22 +865,26 @@ class TestEggInfo: ...@@ -886,22 +865,26 @@ class TestEggInfo:
sources = f.read().split('\n') sources = f.read().split('\n')
assert 'setup.py' in sources assert 'setup.py' in sources
@pytest.mark.parametrize( def _run_egg_info_command(self, tmpdir_cwd, env, cmd=None, output=None):
('make_metadata_path', 'run_command'), environ = os.environ.copy().update(
[ HOME=env.paths['home'],
( )
lambda env: os.path.join('.', 'foo.egg-info', 'PKG-INFO'), if cmd is None:
lambda tmpdir_cwd, env: _run_egg_info_command(tmpdir_cwd, env) cmd = [
), 'egg_info',
( ]
lambda env: os.path.join(env, 'foo.dist-info', 'METADATA'), code, data = environment.run_setup_py(
lambda tmpdir_cwd, env: prepare_metadata_for_build_wheel(env) cmd=cmd,
) pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
] data_stream=1,
) env=environ,
def test_egg_info_tag_only_once( )
self, tmpdir_cwd, env, make_metadata_path, run_command assert not code, data
):
if output:
assert output in data
def test_egg_info_tag_only_once(self, tmpdir_cwd, env):
self._create_project() self._create_project()
build_files({ build_files({
'setup.cfg': DALS(""" 'setup.cfg': DALS("""
...@@ -911,10 +894,11 @@ class TestEggInfo: ...@@ -911,10 +894,11 @@ class TestEggInfo:
tag_svn_revision = 0 tag_svn_revision = 0
"""), """),
}) })
run_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
with open(make_metadata_path(env)) as metadata_file: egg_info_dir = os.path.join('.', 'foo.egg-info')
metadata_lines = metadata_file.read().split('\n') with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
assert 'Version: 0.0.0.dev0' in metadata_lines pkg_info_lines = pkginfo_file.read().split('\n')
assert 'Version: 0.0.0.dev0' in pkg_info_lines
def test_get_pkg_info_revision_deprecated(self): def test_get_pkg_info_revision_deprecated(self):
pytest.warns(EggInfoDeprecationWarning, get_pkg_info_revision) pytest.warns(EggInfoDeprecationWarning, get_pkg_info_revision)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment