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

Support [project] table in pyproject.toml (PEP 621) #393

Merged
merged 28 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift click to select a range
ce2ec0d
Start integrating support for PEP 621 metadata
takluyver Feb 20, 2021
62c26e7
Remove f-strings :(
takluyver Feb 20, 2021
6755cd0
Validate that dynamic fields are listed
takluyver Feb 27, 2021
b1a170d
Test loading config for PEP 621 with no dynamic fields
takluyver Feb 27, 2021
7bebd01
Set module name from PEP 621 table
takluyver Feb 27, 2021
6110be5
Remove unused metadata_and_module_from_ini_path function
takluyver Feb 27, 2021
432dc76
Avoid reusing imported modules for getting metadata
takluyver Feb 27, 2021
bd43136
Only get dynamic fields from module contents
takluyver Feb 27, 2021
d8e9c0a
Remove debugging prints
takluyver Feb 27, 2021
02e364c
Some integration tests for PEP 621 metadata
takluyver Feb 27, 2021
6472383
No extra build requirements with statically specified metadata
takluyver Feb 27, 2021
06352f1
Remove stray f-string
takluyver Feb 27, 2021
449a687
Test author metadata from [project] table
takluyver Feb 27, 2021
87cac59
Don't modify dict when creating Metadata object
takluyver Feb 28, 2021
f1090e4
Fix error message
takluyver Mar 8, 2021
bea8d33
Fix starting 'flit install' with statically specified PEP 621 metadata
takluyver Mar 8, 2021
2d6fd33
Fix [build-system] tables for PEP 621 samples
takluyver Mar 8, 2021
91394d5
Version number -> 3.2.0
takluyver Mar 8, 2021
d3043ff
Normalise version number coming from PEP 621 config
takluyver Mar 8, 2021
77eb453
Exercise reading more PEP 621 fields
takluyver Mar 11, 2021
059a130
Correct scripts & gui-scripts tables
takluyver Mar 11, 2021
85b1684
Add keywords & classifiers to PEP 621 samples
takluyver Mar 11, 2021
e781ed7
Add requires-python field to PEP 621 sample
takluyver Mar 11, 2021
97e9918
Test error checking in PEP 621 [project] table
takluyver Mar 11, 2021
c5134d6
Test checking for relative path to README
takluyver Mar 11, 2021
88dde16
Test unrecognised field in project.readme table
takluyver Mar 11, 2021
43b7c54
Use email.headerregistry.Address to format 'name <email@domain>'
takluyver Mar 12, 2021
746afdc
Allow module name != distribution name with PEP 621
takluyver Mar 12, 2021
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
Prev Previous commit
Next Next commit
Test error checking in PEP 621 [project] table
  • Loading branch information
takluyver committed Mar 11, 2021
commit 97e9918fc6c423032299912a14138ebb54dbe37f
8 changes: 4 additions & 4 deletions flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 422,7 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
mtype_base = mimetype.split(';')[0].strip() # e.g. text/x-rst
if mtype_base not in readme_ext_to_content_type.values():
raise ConfigError(
"Unrecognised readme content type: {!r}".format(mtype_base)
"Unrecognised readme content-type: {!r}".format(mtype_base)
)
# TODO: validate content-type parameters (charset, md variant)?
else:
Expand Down Expand Up @@ -512,7 512,7 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
)
if not all(isinstance(k, str) for k in grp.values()):
raise ConfigError(
"[projects.entry-points.*] tables should have string keys"
"[projects.entry-points.*] tables should have string values"
)
if set(proj['entry-points'].keys()) & {'console_scripts', 'gui_scripts'}:
raise ConfigError(
Expand All @@ -525,15 525,15 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
_check_type(proj, 'scripts', dict)
if not all(isinstance(k, str) for k in proj['scripts'].values()):
raise ConfigError(
"[projects.scripts] table should have string keys"
"[projects.scripts] table should have string values"
)
lc.entrypoints['console_scripts'] = proj['scripts']

if 'gui-scripts' in proj:
_check_type(proj, 'gui-scripts', dict)
if not all(isinstance(k, str) for k in proj['gui-scripts'].values()):
raise ConfigError(
"[projects.gui-scripts] table should have string keys"
"[projects.gui-scripts] table should have string values"
)
lc.entrypoints['gui_scripts'] = proj['gui-scripts']

Expand Down
39 changes: 39 additions & 0 deletions flit_core/flit_core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 103,42 @@ def test_bad_include_paths(path, err_match):

with pytest.raises(config.ConfigError, match=err_match):
config.prep_toml_config(toml_cfg, None)

@pytest.mark.parametrize(('proj_bad', 'err_match'), [
({'version': 1}, r'\bstr\b'),
({'license': {'fromage': 2}}, '[Uu]nrecognised'),
({'license': {'file': 'LICENSE', 'text': 'xyz'}}, 'both'),
({'license': {}}, 'required'),
({'keywords': 'foo'}, 'list'),
({'keywords': ['foo', 7]}, 'strings'),
({'entry-points': {'foo': 'module1:main'}}, 'entry-point.*tables'),
({'entry-points': {'group': {'foo': 7}}}, 'entry-point.*string'),
({'entry-points': {'gui_scripts': {'foo': 'a:b'}}}, r'\[project\.gui-scripts\]'),
({'scripts': {'foo': 7}}, 'scripts.*string'),
({'gui-scripts': {'foo': 7}}, 'gui-scripts.*string'),
({'optional-dependencies': {'test': 'requests'}}, 'list.*optional-dep'),
({'optional-dependencies': {'test': [7]}}, 'string.*optional-dep'),
({'dynamic': ['classifiers']}, 'dynamic'),
({'dynamic': ['version']}, r'dynamic.*\[project\]'),
({'authors': ['thomas']}, r'author.*\bdict'),
({'maintainers': [{'title': 'Dr'}]}, r'maintainer.*title'),
])
def test_bad_pep621_info(proj_bad, err_match):
proj = {'name': 'module1', 'version': '1.0', 'description': 'x'}
proj.update(proj_bad)
with pytest.raises(config.ConfigError, match=err_match):
config.read_pep621_metadata(proj, samples_dir / 'pep621')

@pytest.mark.parametrize(('readme', 'err_match'), [
({'file': 'README.rst'}, 'required'),
({'file': 'README.rst', 'content-type': 'text/x-python'}, 'content-type'),
({'file': 'README.rst', 'text': '', 'content-type': 'text/x-rst'}, 'both'),
({'content-type': 'text/x-rst'}, 'required'),
(5, r'readme.*string'),
])
def test_bad_pep621_readme(readme, err_match):
proj = {
'name': 'module1', 'version': '1.0', 'description': 'x', 'readme': readme
}
with pytest.raises(config.ConfigError, match=err_match):
config.read_pep621_metadata(proj, samples_dir / 'pep621')