Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Requires-External metadata #356

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions flit_core/flit_core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
6 changes: 5 additions & 1 deletion flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class ConfigError(ValueError):
metadata_list_fields = {
'classifiers',
'requires',
'dev-requires'
'dev-requires',
'requires-external',
}

metadata_allowed_fields = {
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/samples/requires-external/module1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Example module"""

__version__ = '0.1'
12 changes: 12 additions & 0 deletions tests/samples/requires-external/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["flit"]

[tool.flit.metadata]
module = "module1"
author = "Sir Robin"
author-email = "[email protected]"
home-page = "http://github.com/sirrobin/module1"
requires-external = [
"git",
"ffmpeg",
]
10 changes: 10 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down