summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pbr/core.py2
-rw-r--r--pbr/hooks/backwards.py1
-rw-r--r--pbr/hooks/commands.py5
-rw-r--r--pbr/packaging.py69
-rw-r--r--pbr/tests/__init__.py2
-rw-r--r--pbr/tests/test_core.py49
-rw-r--r--pbr/tests/testpackage/pbr_testpackage/cmd.py19
-rw-r--r--pbr/tests/testpackage/setup.cfg4
-rw-r--r--pbr/tests/util.py4
-rw-r--r--pbr/util.py4
-rw-r--r--requirements.txt1
-rw-r--r--test-requirements-py3.txt10
-rw-r--r--tools/integration.sh66
-rw-r--r--tox.ini6
14 files changed, 211 insertions, 31 deletions
diff --git a/pbr/core.py b/pbr/core.py
index 3e398c3..f622ad0 100644
--- a/pbr/core.py
+++ b/pbr/core.py
@@ -52,7 +52,7 @@ from pbr import util
core.Distribution = dist._get_unpatched(core.Distribution)
if sys.version_info[0] == 3:
string_type = str
- integer_types = int
+ integer_types = (int,)
else:
string_type = basestring
integer_types = (int, long)
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 d14baec..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
@@ -38,6 +40,9 @@ 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/packaging.py b/pbr/packaging.py
index 197a721..8afbde7 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -30,7 +30,9 @@ from distutils.command import install as du_install
import distutils.errors
from distutils import log
import pkg_resources
+from setuptools.command import easy_install
from setuptools.command import install
+from setuptools.command import install_scripts
from setuptools.command import sdist
try:
@@ -273,14 +275,14 @@ def generate_authors(git_dir=None, dest_dir='.', option_dict=dict()):
and not os.access(new_authors, os.W_OK)):
return
log.info('[pbr] Generating AUTHORS')
- jenkins_email = 'jenkins@review'
+ ignore_emails = '(jenkins@review|infra@lists)'
if git_dir is None:
git_dir = _get_git_directory()
if git_dir:
# don't include jenkins email address in AUTHORS file
git_log_cmd = ("git --git-dir=" + git_dir +
" log --format='%aN <%aE>' | sort -u | "
- "egrep -v '" + jenkins_email + "'")
+ "egrep -v '" + ignore_emails + "'")
changelog = _run_shell_command(git_log_cmd)
signed_cmd = ("git log --git-dir=" + git_dir +
" | grep -i Co-authored-by: | sort -u")
@@ -430,6 +432,69 @@ def have_nose():
return _have_nose
+_script_text = """# PBR Generated from %(group)r
+
+import sys
+
+from %(module_name)s import %(func)s
+
+
+if __name__ == "__main__":
+ sys.exit(%(func)s())
+"""
+
+
+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':
+ for name, ep in dist.get_entry_map(group).items():
+ script_text = _script_text % dict(
+ group=group,
+ module_name=ep.module_name,
+ func=ep.attrs[0])
+ yield (name, header+script_text)
+
+
+class LocalInstallScripts(install_scripts.install_scripts):
+ """Intercepts console scripts entry_points."""
+ command_name = 'install_scripts'
+
+ def run(self):
+ if os.name != 'nt':
+ get_script_args = override_get_script_args
+ else:
+ get_script_args = easy_install.get_script_args
+
+ import distutils.command.install_scripts
+
+ self.run_command("egg_info")
+ if self.distribution.scripts:
+ # run first to set up self.outfiles
+ distutils.command.install_scripts.install_scripts.run(self)
+ else:
+ self.outfiles = []
+ if self.no_ep:
+ # don't install entry point scripts into .egg file!
+ return
+
+ ei_cmd = self.get_finalized_command("egg_info")
+ dist = pkg_resources.Distribution(
+ ei_cmd.egg_base,
+ pkg_resources.PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
+ ei_cmd.egg_name, ei_cmd.egg_version,
+ )
+ bs_cmd = self.get_finalized_command('build_scripts')
+ executable = getattr(
+ bs_cmd, 'executable', easy_install.sys_executable)
+ is_wininst = getattr(
+ self.get_finalized_command("bdist_wininst"), '_is_running', False
+ )
+ for args in get_script_args(dist, executable, is_wininst):
+ self.write_script(*args)
+
+
class LocalSDist(sdist.sdist):
"""Builds the ChangeLog and Authors files from VC first."""
diff --git a/pbr/tests/__init__.py b/pbr/tests/__init__.py
index 6c6fb59..160743f 100644
--- a/pbr/tests/__init__.py
+++ b/pbr/tests/__init__.py
@@ -115,7 +115,7 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
def run_setup(self, *args):
return self._run_cmd(sys.executable, ('setup.py',) + args)
- def _run_cmd(self, cmd, args):
+ def _run_cmd(self, cmd, args=[]):
"""Run a command in the root of the test working copy.
Runs a command, with the given argument list, in the root of the test
diff --git a/pbr/tests/test_core.py b/pbr/tests/test_core.py
index f24e5cb..f8e5989 100644
--- a/pbr/tests/test_core.py
+++ b/pbr/tests/test_core.py
@@ -42,6 +42,8 @@ import glob
import os
import tarfile
+import fixtures
+
from pbr import tests
@@ -73,3 +75,50 @@ class TestCore(tests.BaseTestCase):
names = ['/'.join(p.split('/')[1:]) for p in tf.getnames()]
assert 'extra-file.txt' in names
+
+ def test_console_script_install(self):
+ """Test that we install a non-pkg-resources console script."""
+
+ if os.name == 'nt':
+ self.skipTest('Windows support is passthrough')
+
+ stdout, _, return_code = self.run_setup(
+ 'install_scripts', '--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())
+
+ self.useFixture(
+ fixtures.EnvironmentVariable('PYTHONPATH', '.'))
+
+ 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/testpackage/pbr_testpackage/cmd.py b/pbr/tests/testpackage/pbr_testpackage/cmd.py
new file mode 100644
index 0000000..1b03915
--- /dev/null
+++ b/pbr/tests/testpackage/pbr_testpackage/cmd.py
@@ -0,0 +1,19 @@
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+#
+# 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
+
+
+def main():
+ print("PBR Test Command")
diff --git a/pbr/tests/testpackage/setup.cfg b/pbr/tests/testpackage/setup.cfg
index 336668d..9bcc0ee 100644
--- a/pbr/tests/testpackage/setup.cfg
+++ b/pbr/tests/testpackage/setup.cfg
@@ -31,6 +31,10 @@ package-data = testpackage = package_data/*.txt
data-files = testpackage/data_files = data_files/*.txt
extra-files = extra-file.txt
+[entry_points]
+console_scripts =
+ pbr_test_cmd = pbr_testpackage.cmd:main
+
[extension=pbr_testpackage.testext]
sources = src/testext.c
optional = True
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/requirements.txt b/requirements.txt
index 160b352..da917d5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
setuptools_git>=0.4
+pip>=1.0
diff --git a/test-requirements-py3.txt b/test-requirements-py3.txt
deleted file mode 100644
index eba16b8..0000000
--- a/test-requirements-py3.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-coverage>=3.6
-discover
-fixtures>=0.3.12
-flake8
-python-subunit
-sphinx>=1.1.2
--e bzr+lp:testrepository#egg=testrepository
-testresources
-testscenarios
-testtools>=0.9.27
diff --git a/tools/integration.sh b/tools/integration.sh
index 41a350d..b32b303 100644
--- a/tools/integration.sh
+++ b/tools/integration.sh
@@ -27,7 +27,7 @@ BASE=${BASE:-/opt/stack}
REPODIR=${REPODIR:-$BASE/new}
# TODO: Figure out how to get this on to the box properly
-sudo apt-get install -y --force-yes libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libzmq-dev
+sudo apt-get install -y --force-yes libxml2-dev libxslt-dev libmysqlclient-dev libpq-dev libnspr4-dev pkg-config libsqlite3-dev libzmq-dev libffi-dev
tmpdir=`mktemp -d`
@@ -45,11 +45,14 @@ mkdir -p ~/.pip
cat <<EOF > ~/.pip/pip.conf
[global]
-log = /home/jenkins/pip.log
+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
@@ -87,9 +89,52 @@ cat <<EOF > ~/.pip/pip.conf
[global]
index-url = $pypiurl
extra-index-url = http://pypi.openstack.org/openstack
-log = /home/jenkins/pip.log
+log = $HOME/pip.log
EOF
+eptest=$tmpdir/eptest
+mkdir $eptest
+cd $eptest
+
+cat <<EOF > setup.cfg
+[metadata]
+name = test_project
+
+[entry_points]
+console_scripts =
+ test_cmd = test_project:main
+
+[global]
+setup-hooks =
+ pbr.hooks.setup_hook
+EOF
+
+cat <<EOF > setup.py
+import setuptools
+
+setuptools.setup(
+ setup_requires=['pbr'],
+ pbr=True)
+EOF
+
+mkdir test_project
+cat <<EOF > test_project/__init__.py
+def main():
+ print "Test cmd"
+EOF
+
+epvenv=$eptest/venv
+mkvenv $epvenv setuptools pip
+
+eppbrdir=$tmpdir/eppbrdir
+git clone $REPODIR/pbr $eppbrdir
+$epvenv/bin/pip install -e $eppbrdir
+
+PBR_VERSION=0.0 $epvenv/bin/python setup.py install
+cat $epvenv/bin/test_cmd
+grep 'PBR Generated' $epvenv/bin/test_cmd
+$epvenv/bin/test_cmd | grep 'Test cmd'
+
projectdir=$tmpdir/projects
mkdir -p $projectdir
@@ -121,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
@@ -139,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
diff --git a/tox.ini b/tox.ini
index 0c9be27..1cf797c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26,py27,pep8
+envlist = py26,py27,py33,pep8
[testenv]
setenv = VIRTUAL_ENV={envdir}
@@ -11,10 +11,6 @@ deps = -r{toxinidir}/requirements.txt
commands =
python setup.py testr --testr-args='{posargs}'
-[testenv:py33]
-deps = -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements-py3.txt
-
[tox:jenkins]
sitepackages = True
downloadcache = ~/cache/pip