diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2021-03-15 17:22:59 +0000 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2021-03-15 17:25:01 +0000 |
commit | 1d6ae9c59a890a761c7d7b68d6d6cb5f33e1c867 (patch) | |
tree | f75a1ca4c9292a388f124a377d8380ba77998ae9 | |
parent | 5195593256f167d7843c14fa9b8b932bcd2afa34 (diff) | |
download | pbr-1d6ae9c59a890a761c7d7b68d6d6cb5f33e1c867.tar.gz |
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>
-rw-r--r-- | pbr/util.py | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/pbr/util.py b/pbr/util.py index 2d7ef93..8ceacab 100644 --- a/pbr/util.py +++ b/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) |