From 744380f14156519d99c7a0ec6f0fab84413690a1 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Mon, 18 Jul 2022 10:13:53 +0900 Subject: [PATCH] Imported Upstream version 5.6.0 --- .pre-commit-config.yaml | 39 ++++++++++++ .zuul.yaml | 1 - AUTHORS | 1 + ChangeLog | 16 +++++ PKG-INFO | 2 +- doc/requirements.txt | 1 + doc/source/conf.py | 13 ++++ lower-constraints.txt | 37 ----------- pbr.egg-info/PKG-INFO | 2 +- pbr.egg-info/SOURCES.txt | 2 +- pbr/tests/test_packaging.py | 1 - pbr/tests/test_setup.py | 6 +- pbr/tests/test_util.py | 105 ++++++++++++++++++++++++++++++- pbr/util.py | 120 +++++++++++++++++------------------- test-requirements.txt | 7 ++- tools/integration.sh | 2 +- tox.ini | 7 +-- 17 files changed, 243 insertions(+), 119 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100644 lower-constraints.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2f6ad7b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +# We from the Oslo project decided to pin repos based on the +# commit hash instead of the version tag to prevend arbitrary +# code from running in developer's machines. To update to a +# newer version, run `pre-commit autoupdate` and then replace +# the newer versions with their commit hash. + +default_language_version: + python: python3 + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0 + hooks: + - id: trailing-whitespace + # Replaces or checks mixed line ending + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + # Forbid files which have a UTF-8 byte-order marker + - id: check-byte-order-marker + # Checks that non-binary executables have a proper shebang + - id: check-executables-have-shebangs + # Check for files that contain merge conflict strings. + - id: check-merge-conflict + # Check for debugger imports and py37+ breakpoint() + # calls in python source + - id: debug-statements + - id: check-yaml + files: .*\.(yaml|yml)$ + - repo: local + hooks: + - id: flake8 + name: flake8 + additional_dependencies: + - hacking>=4.0.0,<4.1.0 + language: python + entry: flake8 + files: '^.*\.py$' + exclude: '^(doc|releasenotes|tools)/.*$' diff --git a/.zuul.yaml b/.zuul.yaml index ba9b3fa..1765864 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -110,7 +110,6 @@ - lib-forward-testing - lib-forward-testing-python3 - openstack-cover-jobs - - openstack-lower-constraints-jobs - openstack-python-jobs - openstack-python3-ussuri-jobs - periodic-stable-jobs diff --git a/AUTHORS b/AUTHORS index 17a7b62..9587345 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,6 +25,7 @@ Clark Boylan Claudiu Popa Corey Bryant Dan Prince +Daniel Bengtsson Darragh Bailey Davanum Srinivas Dave Walker (Daviey) diff --git a/ChangeLog b/ChangeLog index 170a1fa..84c9827 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,22 @@ CHANGES ======= +5.6.0 +----- + +* Reverse ordering of 'D1\_D2\_SETUP\_ARGS' +* Add test for cfg -> py transformation +* Don't pass empty 'long\_description' +* Move flake8 as a pre-commit local target +* Map requires-python to python-requires (attempt 2) +* Update dependencies to avoid failure with old pip +* Increase OS\_TEST\_TIMEOUT to 1200 +* Prevent test failure due to use of setpref +* util: Convert 'D1\_D2\_SETUP\_ARGS' to a list of tuples +* Revert "Map requires-python to python-requires" +* Dropping lower constraints testing +* Adding pre-commit + 5.5.1 ----- diff --git a/PKG-INFO b/PKG-INFO index 7df1804..8efb07a 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pbr -Version: 5.5.1 +Version: 5.6.0 Summary: Python Build Reasonableness Home-page: https://docs.openstack.org/pbr/latest/ Author: OpenStack diff --git a/doc/requirements.txt b/doc/requirements.txt index d0c1f36..34ce8ba 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -3,3 +3,4 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD sphinxcontrib-apidoc>=0.2.0 # BSD openstackdocstheme>=1.18.1 # Apache-2.0 reno>=2.5.0 # Apache-2.0 +six==1.12.0 # MIT diff --git a/doc/source/conf.py b/doc/source/conf.py index aa51538..d86c682 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,17 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2020 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. import os import sys diff --git a/lower-constraints.txt b/lower-constraints.txt deleted file mode 100644 index 46ad80b..0000000 --- a/lower-constraints.txt +++ /dev/null @@ -1,37 +0,0 @@ -alabaster==0.7.10 -Babel==2.3.4 -docutils==0.11 -dulwich==0.15.0 -extras==1.0.0 -fixtures==3.0.0 -flake8==2.5.5 -hacking==0.12.0 -imagesize==0.7.1 -Jinja2==2.10 -linecache2==1.0.0 -MarkupSafe==1.0 -mccabe==0.2.1 -mock==2.0.0 -openstackdocstheme==1.18.1 -pep8==1.5.7 -pyflakes==0.8.1 -Pygments==2.2.0 -python-mimeparse==1.6.0 -python-subunit==1.0.0 -pytz==2013.6 -PyYAML==3.12 -reno==2.5.0 -requests==2.14.2 -six==1.12.0 -snowballstemmer==1.2.1 -Sphinx==1.6.5 -sphinxcontrib-apidoc==0.2.0 -sphinxcontrib-websupport==1.0.1 -stestr==2.1.0 -testrepository==0.0.18 -testresources==2.0.0 -testscenarios==0.4 -testtools==2.2.0 -traceback2==1.4.0 -unittest2==1.1.0 -virtualenv==20.0.3 diff --git a/pbr.egg-info/PKG-INFO b/pbr.egg-info/PKG-INFO index 7df1804..8efb07a 100644 --- a/pbr.egg-info/PKG-INFO +++ b/pbr.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pbr -Version: 5.5.1 +Version: 5.6.0 Summary: Python Build Reasonableness Home-page: https://docs.openstack.org/pbr/latest/ Author: OpenStack diff --git a/pbr.egg-info/SOURCES.txt b/pbr.egg-info/SOURCES.txt index 779cbf3..2fbcb1d 100644 --- a/pbr.egg-info/SOURCES.txt +++ b/pbr.egg-info/SOURCES.txt @@ -1,5 +1,6 @@ .coveragerc .mailmap +.pre-commit-config.yaml .stestr.conf .zuul.yaml AUTHORS @@ -7,7 +8,6 @@ CONTRIBUTING.rst ChangeLog LICENSE README.rst -lower-constraints.txt setup.cfg setup.py test-requirements.txt diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index 3a70319..9e95a86 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -135,7 +135,6 @@ class GPGKeyFixture(fixtures.Fixture): Name-Comment: N/A Name-Email: example@example.com Expire-Date: 2d - Preferences: (setpref) %commit """) diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py index d171d7c..4307708 100644 --- a/pbr/tests/test_setup.py +++ b/pbr/tests/test_setup.py @@ -218,9 +218,9 @@ class GitLogsTest(base.BaseTestCase): with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh: authors = auth_fh.read() - self.assertTrue(author_old in authors) - self.assertTrue(author_new in authors) - self.assertTrue(co_author in authors) + self.assertIn(author_old, authors) + self.assertIn(author_new, authors) + self.assertIn(co_author, authors) class _SphinxConfig(object): diff --git a/pbr/tests/test_util.py b/pbr/tests/test_util.py index 0a02fc1..f372d65 100644 --- a/pbr/tests/test_util.py +++ b/pbr/tests/test_util.py @@ -38,6 +38,108 @@ def config_from_ini(ini): return config +class TestBasics(base.BaseTestCase): + + def test_basics(self): + self.maxDiff = None + config_text = """ + [metadata] + name = foo + version = 1.0 + author = John Doe + author_email = jd@example.com + maintainer = Jim Burke + maintainer_email = jb@example.com + home_page = http://example.com + summary = A foobar project. + description = Hello, world. This is a long description. + download_url = http://opendev.org/x/pbr + classifier = + Development Status :: 5 - Production/Stable + Programming Language :: Python + platform = + any + license = Apache 2.0 + requires_dist = + Sphinx + requests + setup_requires_dist = + docutils + python_requires = >=3.6 + provides_dist = + bax + provides_extras = + bar + obsoletes_dist = + baz + + [files] + packages_root = src + packages = + foo + package_data = + "" = *.txt, *.rst + foo = *.msg + namespace_packages = + hello + data_files = + bitmaps = + bm/b1.gif + bm/b2.gif + config = + cfg/data.cfg + scripts = + scripts/hello-world.py + modules = + mod1 + """ + expected = { + 'name': u'foo', + 'version': u'1.0', + 'author': u'John Doe', + 'author_email': u'jd@example.com', + 'maintainer': u'Jim Burke', + 'maintainer_email': u'jb@example.com', + 'url': u'http://example.com', + 'description': u'A foobar project.', + 'long_description': u'Hello, world. This is a long description.', + 'download_url': u'http://opendev.org/x/pbr', + 'classifiers': [ + u'Development Status :: 5 - Production/Stable', + u'Programming Language :: Python', + ], + 'platforms': [u'any'], + 'license': u'Apache 2.0', + 'install_requires': [ + u'Sphinx', + u'requests', + ], + 'setup_requires': [u'docutils'], + 'python_requires': u'>=3.6', + 'provides': [u'bax'], + 'provides_extras': [u'bar'], + 'obsoletes': [u'baz'], + 'extras_require': {}, + + 'package_dir': {'': u'src'}, + 'packages': [u'foo'], + 'package_data': { + '': ['*.txt,', '*.rst'], + 'foo': ['*.msg'], + }, + 'namespace_packages': [u'hello'], + 'data_files': [ + ('bitmaps', ['bm/b1.gif', 'bm/b2.gif']), + ('config', ['cfg/data.cfg']), + ], + 'scripts': [u'scripts/hello-world.py'], + 'py_modules': [u'mod1'], + } + config = config_from_ini(config_text) + actual = util.setup_cfg_to_setup_kwargs(config) + self.assertDictEqual(expected, actual) + + class TestExtrasRequireParsingScenarios(base.BaseTestCase): scenarios = [ @@ -197,8 +299,7 @@ class TestDataFilesParsing(base.BaseTestCase): config = config_from_ini(self.config_text) kwargs = util.setup_cfg_to_setup_kwargs(config) - self.assertEqual(self.data_files, - list(kwargs['data_files'])) + self.assertEqual(self.data_files, kwargs['data_files']) class TestUTF8DescriptionFile(base.BaseTestCase): diff --git a/pbr/util.py b/pbr/util.py index 6e8d231..75a7ebb 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -92,47 +92,50 @@ _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",), +CFG_TO_PY_SETUP_ARGS = ( + (('metadata', 'name'), 'name'), + (('metadata', 'version'), 'version'), + (('metadata', 'author'), 'author'), + (('metadata', 'author_email'), 'author_email'), + (('metadata', 'maintainer'), 'maintainer'), + (('metadata', 'maintainer_email'), 'maintainer_email'), + (('metadata', 'home_page'), 'url'), + (('metadata', 'project_urls'), 'project_urls'), + (('metadata', 'summary'), 'description'), + (('metadata', 'keywords'), 'keywords'), + (('metadata', 'description'), 'long_description'), + ( + ('metadata', 'description_content_type'), + 'long_description_content_type', + ), + (('metadata', 'download_url'), 'download_url'), + (('metadata', 'classifier'), 'classifiers'), + (('metadata', 'platform'), 'platforms'), # ** + (('metadata', 'license'), 'license'), # Use setuptools install_requires, not # broken distutils requires - "install_requires": ("metadata", "requires_dist"), - "setup_requires": ("metadata", "setup_requires_dist"), - "python_requires": ("metadata",), - "requires_python": ("metadata", "python_requires"), - "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"), + (('metadata', 'requires_dist'), 'install_requires'), + (('metadata', 'setup_requires_dist'), 'setup_requires'), + (('metadata', 'python_requires'), 'python_requires'), + (('metadata', 'requires_python'), 'python_requires'), + (('metadata', 'provides_dist'), 'provides'), # ** + (('metadata', 'provides_extras'), 'provides_extras'), + (('metadata', 'obsoletes_dist'), 'obsoletes'), # ** + (('files', 'packages_root'), 'package_dir'), + (('files', 'packages'), 'packages'), + (('files', 'package_data'), 'package_data'), + (('files', 'namespace_packages'), 'namespace_packages'), + (('files', 'data_files'), 'data_files'), + (('files', 'scripts'), 'scripts'), + (('files', 'modules'), 'py_modules'), # ** + (('global', 'commands'), 'cmdclass'), # 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",), -} + (('backwards_compat', 'zip_safe'), 'zip_safe'), + (('backwards_compat', 'tests_require'), 'tests_require'), + (('backwards_compat', 'dependency_links'), 'dependency_links'), + (('backwards_compat', 'include_package_data'), 'include_package_data'), +) # setup() arguments that can have multiple values in setup.cfg MULTI_FIELDS = ("classifiers", @@ -312,34 +315,25 @@ 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: - # The distutils field name is different than distutils2's. - section, option = D1_D2_SETUP_ARGS[arg] - - elif len(D1_D2_SETUP_ARGS[arg]) == 1: - # The distutils field name is the same thant distutils2's. - section = D1_D2_SETUP_ARGS[arg][0] - option = arg + for alias, arg in CFG_TO_PY_SETUP_ARGS: + section, option = alias in_cfg_value = has_get_option(config, section, option) + if not in_cfg_value and arg == "long_description": + in_cfg_value = has_get_option(config, section, "description_file") + if in_cfg_value: + in_cfg_value = split_multiline(in_cfg_value) + value = '' + for filename in in_cfg_value: + description_file = io.open(filename, encoding='utf-8') + try: + value += description_file.read().strip() + '\n\n' + finally: + description_file.close() + in_cfg_value = value + if not in_cfg_value: - # There is no such option in the setup.cfg - if arg == "long_description": - in_cfg_value = has_get_option(config, section, - "description_file") - if in_cfg_value: - in_cfg_value = split_multiline(in_cfg_value) - value = '' - for filename in in_cfg_value: - description_file = io.open(filename, encoding='utf-8') - try: - value += description_file.read().strip() + '\n\n' - finally: - description_file.close() - in_cfg_value = value - else: - continue + continue if arg in CSV_FIELDS: in_cfg_value = split_csv(in_cfg_value) @@ -405,7 +399,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): if arg == 'data_files': # the data_files value is a pointlessly different structure # from the package_data value - data_files = data_files.items() + data_files = sorted(data_files.items()) in_cfg_value = data_files elif arg == 'cmdclass': cmdclass = {} diff --git a/test-requirements.txt b/test-requirements.txt index a3c5a11..4d586e4 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,8 +4,9 @@ wheel>=0.32.0 # MIT fixtures>=3.0.0 # Apache-2.0/BSD -hacking>=1.1.0,<4.0.0 # Apache-2.0 -mock>=2.0.0 # BSD +hacking>=1.1.0,<4.0.0;python_version>='3.6' # Apache-2.0 +mock>=2.0.0,<4.0.0;python_version=='2.7' # BSD +mock>=2.0.0;python_version>='3.6' # BSD six>=1.12.0 # MIT stestr>=2.1.0,<3.0;python_version=='2.7' # Apache-2.0 stestr>=2.1.0;python_version>='3.0' # Apache-2.0 @@ -19,3 +20,5 @@ coverage!=4.4,>=4.0 # Apache-2.0 sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD testrepository>=0.0.18 # Apache-2.0/BSD + +pre-commit>=2.6.0;python_version>='3.6' # MIT diff --git a/tools/integration.sh b/tools/integration.sh index 566fc50..13480f9 100644 --- a/tools/integration.sh +++ b/tools/integration.sh @@ -160,7 +160,7 @@ export PBRVERSION export PROJECTS export REPODIR export WHEELHOUSE -export OS_TEST_TIMEOUT=900 +export OS_TEST_TIMEOUT=1200 cd $REPODIR/pbr mkvenv .venv source .venv/bin/activate diff --git a/tox.ini b/tox.ini index 7bc530a..549dd4e 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = commands = stestr run --suppress-attachments {posargs} [testenv:pep8] -commands = flake8 {posargs} +commands = pre-commit run -a [testenv:docs] whitelist_externals = rm @@ -53,8 +53,3 @@ commands = ignore = W504 exclude = .venv,.tox,dist,doc,*.egg,build show-source = true - -[testenv:lower-constraints] -deps = - -c{toxinidir}/lower-constraints.txt - -r{toxinidir}/test-requirements.txt -- 2.34.1