diff options
| author | Benoit Pierre <benoit.pierre@gmail.com> | 2017-07-14 23:56:05 +0200 |
|---|---|---|
| committer | Benoit Pierre <benoit.pierre@gmail.com> | 2017-07-15 06:37:00 +0200 |
| commit | a3ec721ec1e70f1f7aec6c3349ad85b446410809 (patch) | |
| tree | 38d46aa6466859dbe3ddf3af96f8fdc2f1c49dba /setuptools | |
| parent | 2328be3cc556076b91c8ec74da7b85b178dbc574 (diff) | |
| download | external_python_setuptools-a3ec721ec1e70f1f7aec6c3349ad85b446410809.tar.gz external_python_setuptools-a3ec721ec1e70f1f7aec6c3349ad85b446410809.tar.bz2 external_python_setuptools-a3ec721ec1e70f1f7aec6c3349ad85b446410809.zip | |
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.
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/dist.py | 12 | ||||
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 33 |
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) |
