Skip to content

Commit

Permalink
Merge branch 'master' into custom
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisverspuij committed May 13, 2019
2 parents 2888e34 + 55429ef commit de03008
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .gitreview
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gerrit]
host=review.openstack.org
host=review.opendev.org
port=29418
project=openstack-dev/pbr.git
project=openstack/pbr.git
10 changes: 5 additions & 5 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::

Expand Down
8 changes: 6 additions & 2 deletions pbr/hooks/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion pbr/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pbr/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
21 changes: 21 additions & 0 deletions pbr/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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'])
10 changes: 6 additions & 4 deletions pbr/tests/test_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
109 changes: 96 additions & 13 deletions pbr/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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,
Expand All @@ -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'])
2 changes: 1 addition & 1 deletion pbr/tests/testpackage/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
10 changes: 6 additions & 4 deletions pbr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",),
Expand Down Expand Up @@ -146,16 +147,17 @@
"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",)

# setup() arguments that contain boolean values
BOOL_FIELDS = ("use_2to3", "zip_safe", "include_package_data")


CSV_FIELDS = ("keywords",)
CSV_FIELDS = ()


def resolve_name(name):
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions playbooks/legacy/pbr-installation-devstack/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand All @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions playbooks/legacy/pbr-installation-upstream-devstack/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
<https://bugs.launchpad.net/pbr/+bug/1810804>`_ for details. For more
information on ``data_files``, see the `distutils documentation
<https://docs.python.org/2/distutils/setupscript.html#installing-additional-files>`_.
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit de03008

Please sign in to comment.