util: Convert 'D1_D2_SETUP_ARGS' to a list of tuples
Dicts can't have duplicate keys. Lists of tuples can. We're going to need duplicates. Change-Id: Id43ba91585160448ad9737ba958ace5163d26f3d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
5195593256
commit
1d6ae9c59a
85
pbr/util.py
85
pbr/util.py
|
@ -92,46 +92,49 @@ _VERSION_SPEC_RE = re.compile(r'\s*(.*?)\s*\((.*)\)\s*$')
|
|||
# Mappings from setup() keyword arguments to setup.cfg options;
|
||||
# The values are (section, option) tuples, or simply (section,) tuples if
|
||||
# the option has the same name as the setup() argument
|
||||
D1_D2_SETUP_ARGS = {
|
||||
"name": ("metadata",),
|
||||
"version": ("metadata",),
|
||||
"author": ("metadata",),
|
||||
"author_email": ("metadata",),
|
||||
"maintainer": ("metadata",),
|
||||
"maintainer_email": ("metadata",),
|
||||
"url": ("metadata", "home_page"),
|
||||
"project_urls": ("metadata",),
|
||||
"description": ("metadata", "summary"),
|
||||
"keywords": ("metadata",),
|
||||
"long_description": ("metadata", "description"),
|
||||
"long_description_content_type": ("metadata", "description_content_type"),
|
||||
"download_url": ("metadata",),
|
||||
"classifiers": ("metadata", "classifier"),
|
||||
"platforms": ("metadata", "platform"), # **
|
||||
"license": ("metadata",),
|
||||
D1_D2_SETUP_ARGS = (
|
||||
('name', ('metadata',)),
|
||||
('version', ('metadata',)),
|
||||
('author', ('metadata',)),
|
||||
('author_email', ('metadata',)),
|
||||
('maintainer', ('metadata',)),
|
||||
('maintainer_email', ('metadata',)),
|
||||
('url', ('metadata', 'home_page')),
|
||||
('project_urls', ('metadata',)),
|
||||
('description', ('metadata', 'summary')),
|
||||
('keywords', ('metadata',)),
|
||||
('long_description', ('metadata', 'description')),
|
||||
(
|
||||
'long_description_content_type',
|
||||
('metadata', 'description_content_type'),
|
||||
),
|
||||
('download_url', ('metadata',)),
|
||||
('classifiers', ('metadata', 'classifier')),
|
||||
('platforms', ('metadata', 'platform')), # **
|
||||
('license', ('metadata',)),
|
||||
# Use setuptools install_requires, not
|
||||
# broken distutils requires
|
||||
"install_requires": ("metadata", "requires_dist"),
|
||||
"setup_requires": ("metadata", "setup_requires_dist"),
|
||||
"python_requires": ("metadata",),
|
||||
"provides": ("metadata", "provides_dist"), # **
|
||||
"provides_extras": ("metadata",),
|
||||
"obsoletes": ("metadata", "obsoletes_dist"), # **
|
||||
"package_dir": ("files", 'packages_root'),
|
||||
"packages": ("files",),
|
||||
"package_data": ("files",),
|
||||
"namespace_packages": ("files",),
|
||||
"data_files": ("files",),
|
||||
"scripts": ("files",),
|
||||
"py_modules": ("files", "modules"), # **
|
||||
"cmdclass": ("global", "commands"),
|
||||
('install_requires', ('metadata', 'requires_dist')),
|
||||
('setup_requires', ('metadata', 'setup_requires_dist')),
|
||||
('python_requires', ('metadata',)),
|
||||
('provides', ('metadata', 'provides_dist')), # **
|
||||
('provides_extras', ('metadata',)),
|
||||
('obsoletes', ('metadata', 'obsoletes_dist')), # **
|
||||
('package_dir', ('files', 'packages_root')),
|
||||
('packages', ('files',)),
|
||||
('package_data', ('files',)),
|
||||
('namespace_packages', ('files',)),
|
||||
('data_files', ('files',)),
|
||||
('scripts', ('files',)),
|
||||
('py_modules', ('files', 'modules')), # **
|
||||
('cmdclass', ('global', 'commands')),
|
||||
# Not supported in distutils2, but provided for
|
||||
# backwards compatibility with setuptools
|
||||
"zip_safe": ("backwards_compat", "zip_safe"),
|
||||
"tests_require": ("backwards_compat", "tests_require"),
|
||||
"dependency_links": ("backwards_compat",),
|
||||
"include_package_data": ("backwards_compat",),
|
||||
}
|
||||
('zip_safe', ('backwards_compat', 'zip_safe')),
|
||||
('tests_require', ('backwards_compat', 'tests_require')),
|
||||
('dependency_links', ('backwards_compat',)),
|
||||
('include_package_data', ('backwards_compat',)),
|
||||
)
|
||||
|
||||
# setup() arguments that can have multiple values in setup.cfg
|
||||
MULTI_FIELDS = ("classifiers",
|
||||
|
@ -311,14 +314,14 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
|
|||
# parse env_markers.
|
||||
all_requirements = {}
|
||||
|
||||
for arg in D1_D2_SETUP_ARGS:
|
||||
if len(D1_D2_SETUP_ARGS[arg]) == 2:
|
||||
for arg, alias in D1_D2_SETUP_ARGS:
|
||||
if len(alias) == 2:
|
||||
# The distutils field name is different than distutils2's.
|
||||
section, option = D1_D2_SETUP_ARGS[arg]
|
||||
section, option = alias
|
||||
|
||||
elif len(D1_D2_SETUP_ARGS[arg]) == 1:
|
||||
elif len(alias) == 1:
|
||||
# The distutils field name is the same thant distutils2's.
|
||||
section = D1_D2_SETUP_ARGS[arg][0]
|
||||
section = alias[0]
|
||||
option = arg
|
||||
|
||||
in_cfg_value = has_get_option(config, section, option)
|
||||
|
|
Loading…
Reference in New Issue