@@ -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