aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setuptools/dist.py12
-rw-r--r--setuptools/tests/test_egg_info.py33
2 files changed, 41 insertions, 4 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index d77d56b1..9a034db5 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -358,7 +358,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
Fix environment markers in `install_requires` and `extras_require`.
- move requirements in `install_requires` that are using environment
- markers to `extras_require`.
+ markers or extras to `extras_require`.
- convert requirements in `extras_require` of the form
`"extra": ["barbazquux; {marker}"]` to
`"extra:{marker}": ["barbazquux"]`.
@@ -379,11 +379,17 @@ class Distribution(Distribution_parse_config_files, _Distribution):
getattr(self, 'install_requires', None) or ()
):
marker = r.marker
- if not marker:
+ extras = r.extras
+ if not marker and not extras:
install_requires.append(r)
continue
+ r.extras = ()
r.marker = None
- extras_require[':' + str(marker)].append(r)
+ for e in extras or ('',):
+ section = e
+ if marker:
+ section += ':' + str(marker)
+ extras_require[section].append(r)
self.extras_require = dict(
(k, [str(r) for r in v])
for k, v in extras_require.items()
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 0b6f06b2..5ea55d61 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -188,7 +188,7 @@ class TestEggInfo(object):
)
invalid_marker = "<=>++"
- def test_install_requires_with_markers(self, tmpdir_cwd, env):
+ def test_install_requires_with_marker(self, tmpdir_cwd, env):
tmpl = 'install_requires=["barbazquux;{marker}"],'
req = tmpl.format(marker=self.mismatch_marker)
self._setup_script_with_requires(req)
@@ -204,6 +204,37 @@ class TestEggInfo(object):
assert install_requires.lstrip() == expected_requires
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
+ def test_install_requires_with_extra(self, tmpdir_cwd, env):
+ req = 'install_requires=["barbazquux [test]"],'
+ self._setup_script_with_requires(req)
+ self._run_install_command(tmpdir_cwd, env)
+ egg_info_dir = self._find_egg_info_files(env.paths['lib']).base
+ requires_txt = os.path.join(egg_info_dir, 'requires.txt')
+ with open(requires_txt) as fp:
+ install_requires = fp.read()
+ expected_requires = DALS('''
+ [test]
+ barbazquux
+ ''')
+ assert install_requires.lstrip() == expected_requires
+ assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
+
+ def test_install_requires_with_extra_and_marker(self, tmpdir_cwd, env):
+ tmpl = 'install_requires=["barbazquux [test]; {marker}"],'
+ req = tmpl.format(marker=self.mismatch_marker)
+ self._setup_script_with_requires(req)
+ self._run_install_command(tmpdir_cwd, env)
+ egg_info_dir = self._find_egg_info_files(env.paths['lib']).base
+ requires_txt = os.path.join(egg_info_dir, 'requires.txt')
+ with open(requires_txt) as fp:
+ install_requires = fp.read()
+ expected_requires = DALS('''
+ [test:{marker}]
+ barbazquux
+ ''').format(marker=self.mismatch_marker_alternate)
+ assert install_requires.lstrip() == expected_requires
+ assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
+
def test_setup_requires_with_markers(self, tmpdir_cwd, env):
tmpl = 'setup_requires=["barbazquux;{marker}"],'
req = tmpl.format(marker=self.mismatch_marker)