Skip to content

Commit

Permalink
Merge pull request #433 from takluyver/install-pep621-deps-only
Browse files Browse the repository at this point in the history
Fix installing dependencies specified in [project] table
  • Loading branch information
takluyver committed Aug 16, 2021
2 parents 0329523 + 4270d36 commit 301d447
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 8 additions & 8 deletions flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:

if 'dependencies' in proj:
_check_list_of_str(proj, 'dependencies')
md_dict['requires_dist'] = proj['dependencies']
reqs_noextra = proj['dependencies']
else:
reqs_noextra = []

if 'optional-dependencies' in proj:
_check_type(proj, 'optional-dependencies', dict)
Expand All @@ -566,16 +568,14 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
'Expected a string list for optional-dependencies ({})'.format(e)
)

reqs_noextra = md_dict.pop('requires_dist', [])
lc.reqs_by_extra = optdeps.copy()

# Add optional-dependencies into requires_dist
md_dict['requires_dist'] = \
reqs_noextra + list(_expand_requires_extra(lc.reqs_by_extra))

md_dict['provides_extra'] = sorted(lc.reqs_by_extra.keys())

# For internal use, record the main requirements as a '.none' extra.
md_dict['requires_dist'] = \
reqs_noextra + list(_expand_requires_extra(lc.reqs_by_extra))

# For internal use, record the main requirements as a '.none' extra.
if reqs_noextra:
lc.reqs_by_extra['.none'] = reqs_noextra

if 'dynamic' in proj:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
dependencies = [
"requests >= 2.18",
"docutils",
]
] # N.B. Using this to check behaviour with dependencies but no optional deps

[project.urls]
homepage = "http://github.com/sirrobin/module1"
Expand Down
4 changes: 4 additions & 0 deletions flit_core/flit_core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def test_load_pep621_nodynamic():
assert inf.metadata['summary'] == 'Statically specified description'
assert set(inf.dynamic_metadata) == set()

# Filling reqs_by_extra when dependencies were specified but no optional
# dependencies was a bug.
assert inf.reqs_by_extra == {'.none': ['requests >= 2.18', 'docutils']}

def test_misspelled_key():
with pytest.raises(config.ConfigError) as e_info:
config.read_flit_config(samples_dir / 'misspelled-key.toml')
Expand Down

0 comments on commit 301d447

Please sign in to comment.