summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/index.rst8
-rw-r--r--pbr/hooks/backwards.py1
-rw-r--r--pbr/hooks/commands.py4
-rw-r--r--pbr/hooks/files.py21
-rw-r--r--pbr/packaging.py5
-rw-r--r--pbr/tests/__init__.py15
-rw-r--r--pbr/tests/test_core.py24
-rw-r--r--pbr/tests/test_files.py80
-rw-r--r--pbr/tests/test_setup.py36
-rw-r--r--pbr/tests/util.py4
-rw-r--r--pbr/util.py4
-rw-r--r--tools/integration.sh17
12 files changed, 181 insertions, 38 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 018b800..d3761d7 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -104,6 +104,7 @@ A simple sample can be found in pbr s own setup.cfg
packages =
pbr
data_files =
+ etc/pbr = etc/*
etc/init =
pbr.packaging.conf
pbr.version.conf
@@ -151,10 +152,12 @@ namespace packages.
that contains key value pairs which specify target directory and source
file to install there. More than one source file for a directory may be
indicated with a further indented list. Source files are stripped of leading
-directories, so::
+directories. Additionally, `pbr` supports a simple file globbing syntax
+for installing entire directory structures, so::
[files]
data_files =
+ etc/pbr = etc/pbr/*
etc/neutron =
etc/api-paste.ini
etc/dhcp-agent.ini
@@ -165,6 +168,9 @@ both of which pbr will expect to find in the `etc` directory in the root of
the source tree. Additionally, `neutron.init` from that dir will be installed
in `/etc/init.d`.
+All of the files and directories located under `etc/pbr` in the source tree
+will be installed into `/etc/pbr`.
+
entry_points
------------
diff --git a/pbr/hooks/backwards.py b/pbr/hooks/backwards.py
index de92eef..d9183b3 100644
--- a/pbr/hooks/backwards.py
+++ b/pbr/hooks/backwards.py
@@ -24,6 +24,7 @@ class BackwardsCompatConfig(base.BaseConfig):
section = 'backwards_compat'
def hook(self):
+ self.config['include_package_data'] = 'True'
packaging.append_text_list(
self.config, 'dependency_links',
packaging.parse_dependency_links())
diff --git a/pbr/hooks/commands.py b/pbr/hooks/commands.py
index a5ed4a6..0171d0d 100644
--- a/pbr/hooks/commands.py
+++ b/pbr/hooks/commands.py
@@ -17,6 +17,8 @@
import os
+from setuptools.command import easy_install
+
from pbr.hooks import base
from pbr import packaging
@@ -39,6 +41,8 @@ class CommandsConfig(base.BaseConfig):
def hook(self):
self.add_command('pbr.packaging.LocalSDist')
self.add_command('pbr.packaging.LocalInstallScripts')
+ if os.name != 'nt':
+ easy_install.get_script_args = packaging.override_get_script_args
if packaging.have_sphinx():
self.add_command('pbr.packaging.LocalBuildDoc')
diff --git a/pbr/hooks/files.py b/pbr/hooks/files.py
index fb6a9bf..ba24aac 100644
--- a/pbr/hooks/files.py
+++ b/pbr/hooks/files.py
@@ -50,6 +50,25 @@ class FilesConfig(base.BaseConfig):
self.config['data_files'] = self.data_files
super(FilesConfig, self).save()
+ def expand_globs(self):
+ finished = []
+ for line in self.data_files.split("\n"):
+ if line.rstrip().endswith('*') and '=' in line:
+ (target, source_glob) = line.split('=')
+ source_prefix = source_glob.strip()[:-1]
+ target = target.strip()
+ 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))
+ finished.extend(
+ [" %s" % os.path.join(dirpath, f) for f in fnames])
+ else:
+ finished.append(line)
+
+ self.data_files = "\n".join(finished)
+
def add_man_path(self, man_path):
self.data_files = "%s\n%s =" % (self.data_files, man_path)
@@ -71,6 +90,8 @@ class FilesConfig(base.BaseConfig):
if os.path.isdir(package):
self.config['packages'] = find_package.smart_find_packages(package)
+ self.expand_globs()
+
if 'manpages' in self.pbr_config:
man_sections = self.get_man_sections()
for (section, pages) in man_sections.items():
diff --git a/pbr/packaging.py b/pbr/packaging.py
index c33f401..8afbde7 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -444,7 +444,8 @@ if __name__ == "__main__":
"""
-def _get_script_args(dist, executable, is_wininst):
+def override_get_script_args(
+ dist, executable=os.path.normpath(sys.executable), is_wininst=False):
"""Override entrypoints console_script."""
header = easy_install.get_script_header("", executable, is_wininst)
for group in 'console_scripts', 'gui_scripts':
@@ -462,7 +463,7 @@ class LocalInstallScripts(install_scripts.install_scripts):
def run(self):
if os.name != 'nt':
- get_script_args = _get_script_args
+ get_script_args = override_get_script_args
else:
get_script_args = easy_install.get_script_args
diff --git a/pbr/tests/__init__.py b/pbr/tests/__init__.py
index 74e4527..8cffb4e 100644
--- a/pbr/tests/__init__.py
+++ b/pbr/tests/__init__.py
@@ -53,6 +53,21 @@ import testtools
from pbr import packaging
+class DiveDir(fixtures.Fixture):
+ """Dive into given directory and return back on cleanup.
+
+ :ivar path: The target directory.
+ """
+
+ def __init__(self, path):
+ self.path = path
+
+ def setUp(self):
+ super(DiveDir, self).setUp()
+ self.addCleanup(os.chdir, os.getcwd())
+ os.chdir(self.path)
+
+
class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
def setUp(self):
diff --git a/pbr/tests/test_core.py b/pbr/tests/test_core.py
index 4b6c49b..f8e5989 100644
--- a/pbr/tests/test_core.py
+++ b/pbr/tests/test_core.py
@@ -98,3 +98,27 @@ class TestCore(tests.BaseTestCase):
stdout, _, return_code = self._run_cmd(
os.path.join(self.temp_dir, 'pbr_test_cmd'))
self.assertIn("PBR", stdout)
+
+ def test_console_script_develop(self):
+ """Test that we develop a non-pkg-resources console script."""
+
+ if os.name == 'nt':
+ self.skipTest('Windows support is passthrough')
+
+ self.useFixture(
+ fixtures.EnvironmentVariable(
+ 'PYTHONPATH', ".:%s" % self.temp_dir))
+
+ stdout, _, return_code = self.run_setup(
+ 'develop', '--install-dir=%s' % self.temp_dir)
+
+ self.assertIn(
+ 'Installing pbr_test_cmd script to %s' % self.temp_dir,
+ stdout)
+ self.assertNotIn(
+ 'pkg_resources',
+ open(os.path.join(self.temp_dir, 'pbr_test_cmd'), 'r').read())
+
+ stdout, _, return_code = self._run_cmd(
+ os.path.join(self.temp_dir, 'pbr_test_cmd'))
+ self.assertIn("PBR", stdout)
diff --git a/pbr/tests/test_files.py b/pbr/tests/test_files.py
new file mode 100644
index 0000000..3805339
--- /dev/null
+++ b/pbr/tests/test_files.py
@@ -0,0 +1,80 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# 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.
+
+from __future__ import print_function
+
+import os
+
+import fixtures
+
+from pbr.hooks import files
+from pbr import tests
+
+
+class FilesConfigTest(tests.BaseTestCase):
+
+ def setUp(self):
+ super(FilesConfigTest, self).setUp()
+
+ pkg_fixture = fixtures.PythonPackage(
+ "fake_package", [
+ ("fake_module.py", b""),
+ ("other_fake_module.py", b""),
+ ])
+ self.useFixture(pkg_fixture)
+ pkg_etc = os.path.join(pkg_fixture.base, 'etc')
+ 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)
+ 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(subpackage, "__init__.py"), 'w') as foo_file:
+ foo_file.write("# empty")
+
+ self.useFixture(tests.DiveDir(pkg_fixture.base))
+
+ def test_implicit_auto_package(self):
+ config = dict(
+ files=dict(
+ )
+ )
+ files.FilesConfig(config, 'fake_package').run()
+ self.assertIn('subpackage', config['files']['packages'])
+
+ def test_auto_package(self):
+ config = dict(
+ files=dict(
+ packages='fake_package',
+ )
+ )
+ files.FilesConfig(config, 'fake_package').run()
+ self.assertIn('subpackage', config['files']['packages'])
+
+ def test_data_files_globbing(self):
+ config = dict(
+ files=dict(
+ data_files="\n etc/pbr = etc/*"
+ )
+ )
+ files.FilesConfig(config, 'fake_package').run()
+ self.assertIn(
+ '\netc/pbr/ = \n etc/foo\netc/pbr/sub = \n etc/sub/bar',
+ config['files']['data_files'])
diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py
index 21c28f3..398c503 100644
--- a/pbr/tests/test_setup.py
+++ b/pbr/tests/test_setup.py
@@ -4,17 +4,17 @@
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
-# 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
+# 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
+# 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.
+# 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.
from __future__ import print_function
@@ -36,22 +36,6 @@ from pbr import packaging
from pbr import tests
-class DiveDir(fixtures.Fixture):
- """Dive into given directory and return back on cleanup.
-
- :ivar path: The target directory.
- """
-
- def __init__(self, path):
- self.path = path
-
- def setUp(self):
- super(DiveDir, self).setUp()
- self.old_path = os.getcwd()
- os.chdir(self.path)
- self.addCleanup(os.chdir, self.old_path)
-
-
class EmailTestCase(tests.BaseTestCase):
def test_str_dict_replace(self):
@@ -256,7 +240,7 @@ class BuildSphinxTest(tests.BaseTestCase):
pkg_fixture = fixtures.PythonPackage(
"fake_package", [("fake_module.py", b"")])
self.useFixture(pkg_fixture)
- self.useFixture(DiveDir(pkg_fixture.base))
+ self.useFixture(tests.DiveDir(pkg_fixture.base))
def test_build_doc(self):
if self.has_opt:
diff --git a/pbr/tests/util.py b/pbr/tests/util.py
index e657508..de5a740 100644
--- a/pbr/tests/util.py
+++ b/pbr/tests/util.py
@@ -44,9 +44,9 @@ import shutil
import stat
try:
- import configparser
-except ImportError:
import ConfigParser as configparser
+except ImportError:
+ import configparser
@contextlib.contextmanager
diff --git a/pbr/util.py b/pbr/util.py
index 3faa58e..6339116 100644
--- a/pbr/util.py
+++ b/pbr/util.py
@@ -73,9 +73,9 @@ from setuptools.dist import Distribution
from setuptools.extension import Extension
try:
- import configparser
-except ImportError:
import ConfigParser as configparser
+except ImportError:
+ import configparser
import pbr.hooks
diff --git a/tools/integration.sh b/tools/integration.sh
index 1e42aff..b32b303 100644
--- a/tools/integration.sh
+++ b/tools/integration.sh
@@ -48,8 +48,11 @@ cat <<EOF > ~/.pip/pip.conf
log = $HOME/pip.log
EOF
-mkvenv $jeepybvenv 'setuptools>=0.7' pip
-$jeepybvenv/bin/pip install -U git+https://review.openstack.org/p/openstack-infra/jeepyb.git
+jeepybsourcedir=$tmpdir/jeepybsourcedir
+git clone $REPODIR/jeepyb $jeepybsourcedir
+
+mkvenv $jeepybvenv setuptools pip
+$jeepybvenv/bin/pip install -e $jeepybsourcedir
cat <<EOF > $tmpdir/mirror.yaml
cache-root: $tmpdownload
@@ -57,7 +60,7 @@ cache-root: $tmpdownload
mirrors:
- name: openstack
projects:
- - https://github.com/openstack/requirements
+ - file://$REPODIR/requirements
output: $pypidir
EOF
@@ -68,7 +71,6 @@ cd $pbrsdistdir
$jeepybvenv/bin/run-mirror -b remotes/origin/master --verbose -c $tmpdir/mirror.yaml --no-process
$jeepybvenv/bin/pip install -i http://pypi.python.org/simple -d $tmpdownload/pip/openstack 'pip==1.0' 'setuptools>=0.7'
-$jeepybvenv/bin/pip install -i http://pypi.python.org/simple -d $tmpdownload/pip/openstack 'setuptools<0.7'
$jeepybvenv/bin/pip install -i http://pypi.python.org/simple -d $tmpdownload/pip/openstack -r requirements.txt
$jeepybvenv/bin/python setup.py sdist -d $tmpdownload/pip/openstack
@@ -164,7 +166,7 @@ for PROJECT in $PROJECTS ; do
# Test that the tarball installs
cd $tmpdir
tarballvenv=$tmpdir/tarball
- mkvenv $tarballvenv 'setuptools>=0.7' 'pip>=1.3,<1.4'
+ mkvenv $tarballvenv setuptools pip
$tarballvenv/bin/pip install $shortprojectdir/dist/*tar.gz
# Test pip installing
@@ -182,6 +184,11 @@ for PROJECT in $PROJECTS ; do
cd $installprojectdir
$installvenv/bin/python setup.py install
+ # Ensure the install_package_data is doing the thing it should do
+ if [ $SHORT_PROJECT = 'nova' ]; then
+ find $installvenv | grep migrate.cfg
+ fi
+
# TODO(mordred): extend script to do a better job with the mirrir
# easy_install to a file:/// can't handle name case insensitivity
# Test python setup.py develop