diff --git a/flit_core/flit_core/common.py b/flit_core/flit_core/common.py index 828b26b8..e327a9d6 100644 --- a/flit_core/flit_core/common.py +++ b/flit_core/flit_core/common.py @@ -341,6 +341,9 @@ def write_metadata_file(self, fp): for extra in self.provides_extra: fp.write(u'Provides-Extra: {}\n'.format(extra)) + for ext in self.requires_external: + fp.write(u'Requires-External: {}\n'.format(ext)) + if self.description is not None: fp.write(u'\n' + self.description + u'\n') diff --git a/flit_core/flit_core/config.py b/flit_core/flit_core/config.py index 0af9c00c..bb136063 100644 --- a/flit_core/flit_core/config.py +++ b/flit_core/flit_core/config.py @@ -15,7 +15,8 @@ class ConfigError(ValueError): metadata_list_fields = { 'classifiers', 'requires', - 'dev-requires' + 'dev-requires', + 'requires-external', } metadata_allowed_fields = { @@ -305,6 +306,9 @@ def _prep_metadata(md_sect, path): md_dict['provides_extra'] = sorted(res.reqs_by_extra.keys()) + if 'requires-external' in md_dict: + md_dict['requires_external'] = md_dict.pop('requires-external') + # For internal use, record the main requirements as a '.none' extra. res.reqs_by_extra['.none'] = reqs_noextra diff --git a/tests/samples/requires-external/module1.py b/tests/samples/requires-external/module1.py new file mode 100644 index 00000000..87f0370d --- /dev/null +++ b/tests/samples/requires-external/module1.py @@ -0,0 +1,3 @@ +"""Example module""" + +__version__ = '0.1' diff --git a/tests/samples/requires-external/pyproject.toml b/tests/samples/requires-external/pyproject.toml new file mode 100644 index 00000000..bd418918 --- /dev/null +++ b/tests/samples/requires-external/pyproject.toml @@ -0,0 +1,12 @@ +[build-system] +requires = ["flit"] + +[tool.flit.metadata] +module = "module1" +author = "Sir Robin" +author-email = "robin@camelot.uk" +home-page = "http://github.com/sirrobin/module1" +requires-external = [ + "git", + "ffmpeg", +] diff --git a/tests/test_wheel.py b/tests/test_wheel.py index 95572cda..39389d08 100644 --- a/tests/test_wheel.py +++ b/tests/test_wheel.py @@ -71,6 +71,16 @@ def test_entry_points(copy_sample): assert 'console_scripts' in cp.sections() assert 'myplugins' in cp.sections() +def test_requires_external(copy_sample): + td = copy_sample('requires-external') + make_wheel_in(td / 'pyproject.toml', td) + assert_isfile(td / 'module1-0.1-py2.py3-none-any.whl') + with unpack(td / 'module1-0.1-py2.py3-none-any.whl') as td_unpack: + with open(str(Path(td_unpack) / 'module1-0.1.dist-info' / 'METADATA')) as f: + txt = f.read() + assert 'Requires-External: git' in txt + assert 'Requires-External: ffmpeg' in txt + def test_entry_points_conflict(copy_sample): td = copy_sample('entrypoints_conflict') with pytest.raises(EntryPointsConflict):