diff --git a/.gitreview b/.gitreview index 8df29968..ae015c0b 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] -host=review.openstack.org +host=review.opendev.org port=29418 -project=openstack-dev/pbr.git +project=openstack/pbr.git diff --git a/.zuul.yaml b/.zuul.yaml index df57d8d9..0f13f836 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,11 +3,11 @@ parent: legacy-dsvm-base timeout: 7800 required-projects: - - openstack-dev/devstack - - openstack-dev/grenade - - openstack-dev/pbr - - openstack-infra/devstack-gate - - openstack-infra/tripleo-ci + - openstack/devstack + - openstack/grenade + - openstack/pbr + - openstack/devstack-gate + - openstack/tripleo-ci - openstack/aodh - openstack/automaton - openstack/ceilometer diff --git a/doc/source/user/using.rst b/doc/source/user/using.rst index 2e58fee4..3fa75696 100644 --- a/doc/source/user/using.rst +++ b/doc/source/user/using.rst @@ -49,7 +49,7 @@ versions of `setuptools`__. A simple sample can be found in *pbr*'s own [metadata] name = pbr author = OpenStack Foundation - author-email = openstack-dev@lists.openstack.org + author-email = openstack-discuss@lists.openstack.org summary = OpenStack's setup automation in a reusable form description-file = README.rst description-content-type = text/x-rst; charset=UTF-8 @@ -102,7 +102,7 @@ In addition, there are some modifications to other sections: For all other sections, you should refer to either the `setuptools`_ documentation or the documentation of the package that provides the section, -such as the ``extract_mesages`` section provided by Babel__. +such as the ``extract_messages`` section provided by Babel__. .. note:: diff --git a/pbr/hooks/files.py b/pbr/hooks/files.py index 48bf9e31..750ac32c 100644 --- a/pbr/hooks/files.py +++ b/pbr/hooks/files.py @@ -58,8 +58,12 @@ def expand_globs(self): if not target.endswith(os.path.sep): target += os.path.sep for (dirpath, dirnames, fnames) in os.walk(source_prefix): - finished.append( - "%s = " % dirpath.replace(source_prefix, target)) + # As source_prefix is always matched, using replace with a + # a limit of one is always going to replace the path prefix + # and not accidentally replace some text in the middle of + # the path + new_prefix = dirpath.replace(source_prefix, target, 1) + finished.append("%s = " % new_prefix) finished.extend( [" %s" % os.path.join(dirpath, f) for f in fnames]) else: diff --git a/pbr/packaging.py b/pbr/packaging.py index 0435bd0d..c81d639e 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -119,7 +119,8 @@ def egg_fragment(match): continue # Ignore index URL lines - if re.match(r'^\s*(-i|--index-url|--extra-index-url).*', line): + if re.match(r'^\s*(-i|--index-url|--extra-index-url|--find-links).*', + line): continue # Handle nested requirements files such as: diff --git a/pbr/tests/test_core.py b/pbr/tests/test_core.py index 0ee6f532..ccd14aba 100644 --- a/pbr/tests/test_core.py +++ b/pbr/tests/test_core.py @@ -74,7 +74,7 @@ def test_setup_py_keywords(self): self.run_setup('egg_info') stdout, _, _ = self.run_setup('--keywords') - assert stdout == 'packaging,distutils,setuptools' + assert stdout == 'packaging, distutils, setuptools' def test_setup_py_build_sphinx(self): stdout, _, return_code = self.run_setup('build_sphinx') diff --git a/pbr/tests/test_files.py b/pbr/tests/test_files.py index e60b6ca7..ed67f7bc 100644 --- a/pbr/tests/test_files.py +++ b/pbr/tests/test_files.py @@ -35,15 +35,20 @@ def setUp(self): ]) self.useFixture(pkg_fixture) pkg_etc = os.path.join(pkg_fixture.base, 'etc') + pkg_ansible = os.path.join(pkg_fixture.base, 'ansible', + 'kolla-ansible', 'test') pkg_sub = os.path.join(pkg_etc, 'sub') subpackage = os.path.join( pkg_fixture.base, 'fake_package', 'subpackage') os.makedirs(pkg_sub) os.makedirs(subpackage) + os.makedirs(pkg_ansible) with open(os.path.join(pkg_etc, "foo"), 'w') as foo_file: foo_file.write("Foo Data") with open(os.path.join(pkg_sub, "bar"), 'w') as foo_file: foo_file.write("Bar Data") + with open(os.path.join(pkg_ansible, "baz"), 'w') as baz_file: + baz_file.write("Baz Data") with open(os.path.join(subpackage, "__init__.py"), 'w') as foo_file: foo_file.write("# empty") @@ -76,3 +81,19 @@ def test_data_files_globbing(self): self.assertIn( '\netc/pbr/ = \n etc/foo\netc/pbr/sub = \n etc/sub/bar', config['files']['data_files']) + + def test_data_files_globbing_source_prefix_in_directory_name(self): + # We want to test that the string, "docs", is not replaced in a + # subdirectory name, "sub-docs" + config = dict( + files=dict( + data_files="\n share/ansible = ansible/*" + ) + ) + files.FilesConfig(config, 'fake_package').run() + self.assertIn( + '\nshare/ansible/ = ' + '\nshare/ansible/kolla-ansible = ' + '\nshare/ansible/kolla-ansible/test = ' + '\n ansible/kolla-ansible/test/baz', + config['files']['data_files']) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index d19dd05b..853844f4 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -531,11 +531,13 @@ def test_index_present(self): tempdir = tempfile.mkdtemp() requirements = os.path.join(tempdir, 'requirements.txt') with open(requirements, 'w') as f: - f.write('-i https://myindex.local') - f.write(' --index-url https://myindex.local') - f.write(' --extra-index-url https://myindex.local') + f.write('-i https://myindex.local\n') + f.write(' --index-url https://myindex.local\n') + f.write(' --extra-index-url https://myindex.local\n') + f.write('--find-links https://myindex.local\n') + f.write('arequirement>=1.0\n') result = packaging.parse_requirements([requirements]) - self.assertEqual([], result) + self.assertEqual(['arequirement>=1.0'], result) def test_nested_requirements(self): tempdir = tempfile.mkdtemp() diff --git a/pbr/tests/test_util.py b/pbr/tests/test_util.py index 370a7dee..6814ac7b 100644 --- a/pbr/tests/test_util.py +++ b/pbr/tests/test_util.py @@ -23,6 +23,19 @@ from pbr import util +def config_from_ini(ini): + config = {} + if sys.version_info >= (3, 2): + parser = configparser.ConfigParser() + else: + parser = configparser.SafeConfigParser() + ini = textwrap.dedent(six.u(ini)) + parser.readfp(io.StringIO(ini)) + for section in parser.sections(): + config[section] = dict(parser.items(section)) + return config + + class TestExtrasRequireParsingScenarios(base.BaseTestCase): scenarios = [ @@ -64,20 +77,8 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase): {} })] - def config_from_ini(self, ini): - config = {} - if sys.version_info >= (3, 2): - parser = configparser.ConfigParser() - else: - parser = configparser.SafeConfigParser() - ini = textwrap.dedent(six.u(ini)) - parser.readfp(io.StringIO(ini)) - for section in parser.sections(): - config[section] = dict(parser.items(section)) - return config - def test_extras_parsing(self): - config = self.config_from_ini(self.config_text) + config = config_from_ini(self.config_text) kwargs = util.setup_cfg_to_setup_kwargs(config) self.assertEqual(self.expected_extra_requires, @@ -89,3 +90,85 @@ class TestInvalidMarkers(base.BaseTestCase): def test_invalid_marker_raises_error(self): config = {'extras': {'test': "foo :bad_marker>'1.0'"}} self.assertRaises(SyntaxError, util.setup_cfg_to_setup_kwargs, config) + + +class TestMapFieldsParsingScenarios(base.BaseTestCase): + + scenarios = [ + ('simple_project_urls', { + 'config_text': """ + [metadata] + project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/ + Documentation = https://docs.openstack.org/pbr/ + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/ + """, # noqa: E501 + 'expected_project_urls': { + 'Bug Tracker': 'https://bugs.launchpad.net/pbr/', + 'Documentation': 'https://docs.openstack.org/pbr/', + 'Source Code': 'https://git.openstack.org/cgit/openstack-dev/pbr/', # noqa: E501 + }, + }), + ('query_parameters', { + 'config_text': """ + [metadata] + project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/?query=true + Documentation = https://docs.openstack.org/pbr/?foo=bar + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hash + """, # noqa: E501 + 'expected_project_urls': { + 'Bug Tracker': 'https://bugs.launchpad.net/pbr/?query=true', + 'Documentation': 'https://docs.openstack.org/pbr/?foo=bar', + 'Source Code': 'https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hash', # noqa: E501 + }, + }), + ] + + def test_project_url_parsing(self): + config = config_from_ini(self.config_text) + kwargs = util.setup_cfg_to_setup_kwargs(config) + + self.assertEqual(self.expected_project_urls, kwargs['project_urls']) + + +class TestKeywordsParsingScenarios(base.BaseTestCase): + + scenarios = [ + ('keywords_list', { + 'config_text': """ + [metadata] + keywords = + one + two + three + """, # noqa: E501 + 'expected_keywords': ['one', 'two', 'three'], + }, + ), + ('inline_keywords', { + 'config_text': """ + [metadata] + keywords = one, two, three + """, # noqa: E501 + 'expected_keywords': ['one, two, three'], + }), + ] + + def test_keywords_parsing(self): + config = config_from_ini(self.config_text) + kwargs = util.setup_cfg_to_setup_kwargs(config) + + self.assertEqual(self.expected_keywords, kwargs['keywords']) + + +class TestProvidesExtras(base.BaseTestCase): + def test_provides_extras(self): + ini = """ + [metadata] + provides_extras = foo + bar + """ + config = config_from_ini(ini) + kwargs = util.setup_cfg_to_setup_kwargs(config) + self.assertEqual(['foo', 'bar'], kwargs['provides_extras']) diff --git a/pbr/tests/testpackage/setup.cfg b/pbr/tests/testpackage/setup.cfg index bf4c26a2..3929f0db 100644 --- a/pbr/tests/testpackage/setup.cfg +++ b/pbr/tests/testpackage/setup.cfg @@ -4,7 +4,7 @@ name = pbr_testpackage # testing postversioned codepaths. version = 0.1.dev author = OpenStack -author-email = openstack-dev@lists.openstack.org +author-email = openstack-discuss@lists.openstack.org home-page = http://pypi.python.org/pypi/pbr project_urls = Bug Tracker = https://bugs.launchpad.net/pbr/ diff --git a/pbr/util.py b/pbr/util.py index 63e913d9..55d73f8b 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -113,6 +113,7 @@ "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",), @@ -146,7 +147,9 @@ "dependency_links", "setup_requires", "tests_require", - "cmdclass") + "keywords", + "cmdclass", + "provides_extras") # setup() arguments that can have mapping values in setup.cfg MAP_FIELDS = ("project_urls",) @@ -154,8 +157,7 @@ # setup() arguments that contain boolean values BOOL_FIELDS = ("use_2to3", "zip_safe", "include_package_data") - -CSV_FIELDS = ("keywords",) +CSV_FIELDS = () def resolve_name(name): @@ -333,7 +335,7 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): elif arg in MAP_FIELDS: in_cfg_map = {} for i in split_multiline(in_cfg_value): - k, v = i.split('=') + k, v = i.split('=', 1) in_cfg_map[k.strip()] = v.strip() in_cfg_value = in_cfg_map elif arg in BOOL_FIELDS: diff --git a/playbooks/legacy/pbr-installation-devstack/run.yaml b/playbooks/legacy/pbr-installation-devstack/run.yaml index 9b48a340..c3591cec 100644 --- a/playbooks/legacy/pbr-installation-devstack/run.yaml +++ b/playbooks/legacy/pbr-installation-devstack/run.yaml @@ -13,12 +13,12 @@ set -x cat > clonemap.yaml << EOF clonemap: - - name: openstack-infra/devstack-gate + - name: openstack/devstack-gate dest: devstack-gate EOF /usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \ - git://git.openstack.org \ - openstack-infra/devstack-gate + https://opendev.org \ + openstack/devstack-gate executable: /bin/bash chdir: '{{ ansible_user_dir }}/workspace' environment: '{{ zuul | zuul_legacy_vars }}' @@ -30,11 +30,11 @@ # Define the entire projects list here so that what we # test requirements against is independent of what d-g # thinks is relevant. - export PROJECTS="openstack-infra/devstack-gate $PROJECTS" - export PROJECTS="openstack-dev/devstack $PROJECTS" - export PROJECTS="openstack-dev/grenade $PROJECTS" - export PROJECTS="openstack-dev/pbr $PROJECTS" - export PROJECTS="openstack-infra/tripleo-ci $PROJECTS" + export PROJECTS="openstack/devstack-gate $PROJECTS" + export PROJECTS="openstack/devstack $PROJECTS" + export PROJECTS="openstack/grenade $PROJECTS" + export PROJECTS="openstack/pbr $PROJECTS" + export PROJECTS="openstack/tripleo-ci $PROJECTS" export PROJECTS="openstack/aodh $PROJECTS" export PROJECTS="openstack/automaton $PROJECTS" export PROJECTS="openstack/ceilometer $PROJECTS" diff --git a/playbooks/legacy/pbr-installation-upstream-devstack/run.yaml b/playbooks/legacy/pbr-installation-upstream-devstack/run.yaml index a8fb806e..554d44b2 100644 --- a/playbooks/legacy/pbr-installation-upstream-devstack/run.yaml +++ b/playbooks/legacy/pbr-installation-upstream-devstack/run.yaml @@ -13,12 +13,12 @@ set -x cat > clonemap.yaml << EOF clonemap: - - name: openstack-infra/devstack-gate + - name: openstack/devstack-gate dest: devstack-gate EOF /usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \ - git://git.openstack.org \ - openstack-infra/devstack-gate + https://opendev.org \ + openstack/devstack-gate executable: /bin/bash chdir: '{{ ansible_user_dir }}/workspace' environment: '{{ zuul | zuul_legacy_vars }}' @@ -30,11 +30,11 @@ # Define the entire projects list here so that what we # test requirements against is independent of what d-g # thinks is relevant. - export PROJECTS="openstack-infra/devstack-gate $PROJECTS" - export PROJECTS="openstack-dev/devstack $PROJECTS" - export PROJECTS="openstack-dev/grenade $PROJECTS" - export PROJECTS="openstack-dev/pbr $PROJECTS" - export PROJECTS="openstack-infra/tripleo-ci $PROJECTS" + export PROJECTS="openstack/devstack-gate $PROJECTS" + export PROJECTS="openstack/devstack $PROJECTS" + export PROJECTS="openstack/grenade $PROJECTS" + export PROJECTS="openstack/pbr $PROJECTS" + export PROJECTS="openstack/tripleo-ci $PROJECTS" export PROJECTS="openstack/aodh $PROJECTS" export PROJECTS="openstack/automaton $PROJECTS" export PROJECTS="openstack/ceilometer $PROJECTS" diff --git a/releasenotes/notes/fix-global-replace-of-src-prefix-in-glob-eb850b94ca96993e.yaml b/releasenotes/notes/fix-global-replace-of-src-prefix-in-glob-eb850b94ca96993e.yaml new file mode 100644 index 00000000..b2895aa1 --- /dev/null +++ b/releasenotes/notes/fix-global-replace-of-src-prefix-in-glob-eb850b94ca96993e.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixes a bug where the directory names of items specified in ``data_files`` + could be renamed if the source prefix glob was contained within the + directory name. See `bug 1810804 + `_ for details. For more + information on ``data_files``, see the `distutils documentation + `_. diff --git a/releasenotes/notes/fix-keywords-as-cfg-list-6cadc5141429d7f5.yaml b/releasenotes/notes/fix-keywords-as-cfg-list-6cadc5141429d7f5.yaml new file mode 100644 index 00000000..8e9c4657 --- /dev/null +++ b/releasenotes/notes/fix-keywords-as-cfg-list-6cadc5141429d7f5.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fix error when ``keywords`` argument as a cfg list. Previously ``keywords`` + were ``CSV_FIELDS`` and with these changes ``keywords`` are now + ``MULTI_FIELDS``. Refer to https://bugs.launchpad.net/pbr/+bug/1811475 + for more information. diff --git a/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml b/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml new file mode 100644 index 00000000..3898587e --- /dev/null +++ b/releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fix mapping error on values who contains a literal ``=``. Example when + setup.cfg contains content like the following project urls configuration + "project_urls = Documentation = http://foo.bar/?badge=latest". + https://bugs.launchpad.net/pbr/+bug/1817592 diff --git a/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml b/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml new file mode 100644 index 00000000..0d10a264 --- /dev/null +++ b/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + PBR now ignores ``--find-links`` in requirements files. This option is not + a valid ``install_requires`` entry for setuptools and thus breaks + PBR-based installs. diff --git a/setup.cfg b/setup.cfg index 6fa3c423..b26be54c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = pbr author = OpenStack -author-email = openstack-dev@lists.openstack.org +author-email = openstack-discuss@lists.openstack.org summary = Python Build Reasonableness description-file = README.rst diff --git a/tools/integration.sh b/tools/integration.sh index 2a7e7727..3b431e14 100644 --- a/tools/integration.sh +++ b/tools/integration.sh @@ -30,7 +30,7 @@ REPODIR=${REPODIR:-$BASE/new} # TODO: Figure out how to get this on to the box properly sudo apt-get update -sudo apt-get install -y --force-yes libvirt-dev libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libzmq-dev libffi-dev libldap2-dev libsasl2-dev ccache libkrb5-dev liberasurecode-dev libjpeg-dev +sudo apt-get install -y --force-yes libvirt-dev libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libffi-dev libldap2-dev libsasl2-dev ccache libkrb5-dev liberasurecode-dev libjpeg-dev # FOR numpy / pyyaml # The source list has been removed from our apt config so rather than