Reverse ordering of 'D1_D2_SETUP_ARGS'

The previous ordering was confusing and placed new values before old
ones. Switch this order, making it more obvious what we're going *from*
and what we're going *to*. With this reordering, the old name no longer
makes sense so we rename the attribute.

Change-Id: Ic7b71f1093671533c9f17fd621e02299bfbd7a6d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2021-03-15 18:41:03 +00:00
parent f40c41d28f
commit 607b4e0547
1 changed files with 38 additions and 45 deletions

View File

@ -92,49 +92,49 @@ _VERSION_SPEC_RE = re.compile(r'\s*(.*?)\s*\((.*)\)\s*$')
# Mappings from setup() keyword arguments to setup.cfg options; # Mappings from setup() keyword arguments to setup.cfg options;
# The values are (section, option) tuples, or simply (section,) tuples if # The values are (section, option) tuples, or simply (section,) tuples if
# the option has the same name as the setup() argument # the option has the same name as the setup() argument
D1_D2_SETUP_ARGS = ( CFG_TO_PY_SETUP_ARGS = (
('name', ('metadata',)), (('metadata', 'name'), 'name'),
('version', ('metadata',)), (('metadata', 'version'), 'version'),
('author', ('metadata',)), (('metadata', 'author'), 'author'),
('author_email', ('metadata',)), (('metadata', 'author_email'), 'author_email'),
('maintainer', ('metadata',)), (('metadata', 'maintainer'), 'maintainer'),
('maintainer_email', ('metadata',)), (('metadata', 'maintainer_email'), 'maintainer_email'),
('url', ('metadata', 'home_page')), (('metadata', 'home_page'), 'url'),
('project_urls', ('metadata',)), (('metadata', 'project_urls'), 'project_urls'),
('description', ('metadata', 'summary')), (('metadata', 'summary'), 'description'),
('keywords', ('metadata',)), (('metadata', 'keywords'), 'keywords'),
('long_description', ('metadata', 'description')), (('metadata', 'description'), 'long_description'),
( (
'long_description_content_type',
('metadata', 'description_content_type'), ('metadata', 'description_content_type'),
'long_description_content_type',
), ),
('download_url', ('metadata',)), (('metadata', 'download_url'), 'download_url'),
('classifiers', ('metadata', 'classifier')), (('metadata', 'classifier'), 'classifiers'),
('platforms', ('metadata', 'platform')), # ** (('metadata', 'platform'), 'platforms'), # **
('license', ('metadata',)), (('metadata', 'license'), 'license'),
# Use setuptools install_requires, not # Use setuptools install_requires, not
# broken distutils requires # broken distutils requires
('install_requires', ('metadata', 'requires_dist')), (('metadata', 'requires_dist'), 'install_requires'),
('setup_requires', ('metadata', 'setup_requires_dist')), (('metadata', 'setup_requires_dist'), 'setup_requires'),
('python_requires', ('metadata',)), (('metadata', 'python_requires'), 'python_requires'),
('python_requires', ('metadata', 'requires_python')), (('metadata', 'requires_python'), 'python_requires'),
('provides', ('metadata', 'provides_dist')), # ** (('metadata', 'provides_dist'), 'provides'), # **
('provides_extras', ('metadata',)), (('metadata', 'provides_extras'), 'provides_extras'),
('obsoletes', ('metadata', 'obsoletes_dist')), # ** (('metadata', 'obsoletes_dist'), 'obsoletes'), # **
('package_dir', ('files', 'packages_root')), (('files', 'packages_root'), 'package_dir'),
('packages', ('files',)), (('files', 'packages'), 'packages'),
('package_data', ('files',)), (('files', 'package_data'), 'package_data'),
('namespace_packages', ('files',)), (('files', 'namespace_packages'), 'namespace_packages'),
('data_files', ('files',)), (('files', 'data_files'), 'data_files'),
('scripts', ('files',)), (('files', 'scripts'), 'scripts'),
('py_modules', ('files', 'modules')), # ** (('files', 'modules'), 'py_modules'), # **
('cmdclass', ('global', 'commands')), (('global', 'commands'), 'cmdclass'),
# Not supported in distutils2, but provided for # Not supported in distutils2, but provided for
# backwards compatibility with setuptools # backwards compatibility with setuptools
('zip_safe', ('backwards_compat', 'zip_safe')), (('backwards_compat', 'zip_safe'), 'zip_safe'),
('tests_require', ('backwards_compat', 'tests_require')), (('backwards_compat', 'tests_require'), 'tests_require'),
('dependency_links', ('backwards_compat',)), (('backwards_compat', 'dependency_links'), 'dependency_links'),
('include_package_data', ('backwards_compat',)), (('backwards_compat', 'include_package_data'), 'include_package_data'),
) )
# setup() arguments that can have multiple values in setup.cfg # setup() arguments that can have multiple values in setup.cfg
@ -315,15 +315,8 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
# parse env_markers. # parse env_markers.
all_requirements = {} all_requirements = {}
for arg, alias in D1_D2_SETUP_ARGS: for alias, arg in CFG_TO_PY_SETUP_ARGS:
if len(alias) == 2: section, option = alias
# The distutils field name is different than distutils2's.
section, option = alias
elif len(alias) == 1:
# The distutils field name is the same as distutils2's.
section = alias[0]
option = arg
in_cfg_value = has_get_option(config, section, option) in_cfg_value = has_get_option(config, section, option)
if not in_cfg_value and arg == "long_description": if not in_cfg_value and arg == "long_description":