Commit a3ec721e authored by Benoit Pierre's avatar Benoit Pierre

fix `install_requires` handling of extras

Internally move requirements in `install_requires` that are using
extras to `extras_require` so those extras don't get stripped when
building wheels.
parent 2328be3c
......@@ -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()
......
......@@ -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)
......
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