Skip to content

Commit f62d8ba

Browse files
authored
Merge branch 'master' into dataflake/trusted_publishing
2 parents 780d748 + f65223e commit f62d8ba

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ classifiers = [
2626
"Natural Language :: English",
2727
"Operating System :: OS Independent",
2828
]
29+
dynamic = ["readme"]
2930
requires-python = ">=3.10"
3031
authors = [
3132
{name = "Zope Foundation and contributors",email = "[email protected]"},

src/zope/meta/setup_to_pyproject.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,27 @@ def setup_args_to_toml_dict(setup_py_path, setup_kwargs):
145145
new_classifiers.append(classifier)
146146
p_data['classifiers'] = new_classifiers
147147

148-
if (setup_py_path.parent / 'README.rst').exists():
149-
p_data['readme'] = 'README.rst'
150-
elif (setup_py_path.parent / 'README.txt').exists():
151-
p_data['readme'] = 'README.txt'
148+
readme = None
149+
for readme_name in ('README.rst', 'README.txt'):
150+
if (setup_py_path.parent / readme_name).exists():
151+
readme = readme_name
152+
break
153+
154+
changelog = None
155+
for changelog_name in ('CHANGES.rst', 'CHANGES.txt'):
156+
if (setup_py_path.parent / changelog_name).exists():
157+
changelog = changelog_name
158+
break
159+
160+
if readme and not changelog:
161+
p_data['readme'] = readme
162+
elif readme and changelog:
163+
readme_spec = tomlkit.inline_table()
164+
readme_spec.update({'file': [readme, changelog]})
165+
toml_dict['tool'] = {
166+
'setuptools': {'dynamic': {'readme': readme_spec}}}
167+
dynamic_attributes = p_data.setdefault('dynamic', [])
168+
dynamic_attributes.append('readme')
152169
else:
153170
print('XXX WARNING XXX: This package has no README.rst or README.txt!')
154171

@@ -298,8 +315,9 @@ def recursive_merge(dict1, dict2):
298315
# We will not overwrite existing values!
299316
if key not in dict1:
300317
dict1[key] = value
318+
return dict1
301319

302-
recursive_merge(p_toml, toml_dict)
320+
p_toml = recursive_merge(p_toml, toml_dict)
303321

304322
# Format long lists
305323
p_toml['project']['classifiers'].multiline(True)

0 commit comments

Comments
 (0)