diff options
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | pbr/core.py | 4 | ||||
-rw-r--r-- | pbr/d2to1/tests/__init__.py | 86 | ||||
-rw-r--r-- | pbr/d2to1/tests/testpackage/d2to1_testpackage/__init__.py | 0 | ||||
-rw-r--r-- | pbr/hooks/backwards.py | 1 | ||||
-rw-r--r-- | pbr/hooks/commands.py | 1 | ||||
-rw-r--r-- | pbr/packaging.py | 64 | ||||
-rw-r--r-- | pbr/tests/__init__.py | 64 | ||||
-rw-r--r-- | pbr/tests/test_commands.py (renamed from pbr/d2to1/tests/test_commands.py) | 4 | ||||
-rw-r--r-- | pbr/tests/test_core.py (renamed from pbr/d2to1/tests/test_core.py) | 29 | ||||
-rw-r--r-- | pbr/tests/test_hooks.py (renamed from pbr/d2to1/tests/test_hooks.py) | 18 | ||||
-rw-r--r-- | pbr/tests/testpackage/CHANGES.txt (renamed from pbr/d2to1/tests/testpackage/CHANGES.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/LICENSE.txt (renamed from pbr/d2to1/tests/testpackage/LICENSE.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/MANIFEST.in (renamed from pbr/d2to1/tests/testpackage/MANIFEST.in) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/README.txt (renamed from pbr/d2to1/tests/testpackage/README.txt) | 2 | ||||
-rw-r--r-- | pbr/tests/testpackage/data_files/a.txt (renamed from pbr/d2to1/tests/testpackage/data_files/a.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/data_files/b.txt (renamed from pbr/d2to1/tests/testpackage/data_files/b.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/data_files/c.rst (renamed from pbr/d2to1/tests/testpackage/data_files/c.rst) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/extra-file.txt (renamed from pbr/d2to1/tests/testpackage/extra-file.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/pbr_testpackage/__init__.py (renamed from pbr/d2to1/__init__.py) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/pbr_testpackage/_setup_hooks.py (renamed from pbr/d2to1/tests/testpackage/d2to1_testpackage/_setup_hooks.py) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/pbr_testpackage/cmd.py | 19 | ||||
-rw-r--r-- | pbr/tests/testpackage/pbr_testpackage/package_data/1.txt (renamed from pbr/d2to1/tests/testpackage/d2to1_testpackage/package_data/1.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/pbr_testpackage/package_data/2.txt (renamed from pbr/d2to1/tests/testpackage/d2to1_testpackage/package_data/2.txt) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/setup.cfg (renamed from pbr/d2to1/tests/testpackage/setup.cfg) | 28 | ||||
-rwxr-xr-x | pbr/tests/testpackage/setup.py (renamed from pbr/d2to1/tests/testpackage/setup.py) | 0 | ||||
-rw-r--r-- | pbr/tests/testpackage/src/testext.c (renamed from pbr/d2to1/tests/testpackage/src/testext.c) | 0 | ||||
-rw-r--r-- | pbr/tests/util.py (renamed from pbr/d2to1/tests/util.py) | 0 | ||||
-rw-r--r-- | pbr/util.py (renamed from pbr/d2to1/util.py) | 14 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | test-requirements-py3.txt | 10 | ||||
-rw-r--r-- | tools/integration.sh | 51 | ||||
-rw-r--r-- | tox.ini | 6 |
33 files changed, 265 insertions, 141 deletions
@@ -124,9 +124,6 @@ A simple sample can be found in pbr s own setup.cfg [files] packages = oslo - [hooks] - setup-hooks = - pbr.hooks.setup_hook The minimal setup.py should look something like this:: diff --git a/pbr/core.py b/pbr/core.py index 8cee9b0..f622ad0 100644 --- a/pbr/core.py +++ b/pbr/core.py @@ -46,13 +46,13 @@ import warnings from setuptools import dist -from pbr.d2to1 import util +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/d2to1/tests/__init__.py b/pbr/d2to1/tests/__init__.py deleted file mode 100644 index c9144bb..0000000 --- a/pbr/d2to1/tests/__init__.py +++ /dev/null @@ -1,86 +0,0 @@ -# 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. -# -# Copyright (C) 2013 Association of Universities for Research in Astronomy -# (AURA) -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. The name of AURA and its representatives may not be used to -# endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - -import os -import shutil -import subprocess -import sys - -import fixtures -import testtools - - -class D2to1TestCase(testtools.TestCase): - def setUp(self): - super(D2to1TestCase, self).setUp() - self.temp_dir = self.useFixture(fixtures.TempDir()).path - self.package_dir = os.path.join(self.temp_dir, 'testpackage') - shutil.copytree(os.path.join(os.path.dirname(__file__), 'testpackage'), - self.package_dir) - self.addCleanup(os.chdir, os.getcwd()) - os.chdir(self.package_dir) - - def tearDown(self): - # Remove d2to1.testpackage from sys.modules so that it can be freshly - # re-imported by the next test - for k in list(sys.modules): - if (k == 'd2to1_testpackage' or - k.startswith('d2to1_testpackage.')): - del sys.modules[k] - super(D2to1TestCase, self).tearDown() - - def run_setup(self, *args): - return self._run_cmd(sys.executable, ('setup.py',) + 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 - working copy--returns the stdout and stderr streams and the exit code - from the subprocess. - """ - - os.chdir(self.package_dir) - p = subprocess.Popen([cmd] + list(args), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - - streams = tuple(s.decode('latin1').strip() for s in p.communicate()) - print(streams) - return (streams) + (p.returncode,) diff --git a/pbr/d2to1/tests/testpackage/d2to1_testpackage/__init__.py b/pbr/d2to1/tests/testpackage/d2to1_testpackage/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/pbr/d2to1/tests/testpackage/d2to1_testpackage/__init__.py +++ /dev/null diff --git a/pbr/hooks/backwards.py b/pbr/hooks/backwards.py index d9183b3..de92eef 100644 --- a/pbr/hooks/backwards.py +++ b/pbr/hooks/backwards.py @@ -24,7 +24,6 @@ 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..a5ed4a6 100644 --- a/pbr/hooks/commands.py +++ b/pbr/hooks/commands.py @@ -38,6 +38,7 @@ class CommandsConfig(base.BaseConfig): def hook(self): self.add_command('pbr.packaging.LocalSDist') + self.add_command('pbr.packaging.LocalInstallScripts') if packaging.have_sphinx(): self.add_command('pbr.packaging.LocalBuildDoc') diff --git a/pbr/packaging.py b/pbr/packaging.py index bae9816..c33f401 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: @@ -430,6 +432,68 @@ 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 _get_script_args(dist, executable, is_wininst): + """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 = _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 4814cfa..14a5b5e 100644 --- a/pbr/tests/__init__.py +++ b/pbr/tests/__init__.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010-2011 OpenStack Foundation +# 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 @@ -13,10 +14,37 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +# Copyright (C) 2013 Association of Universities for Research in Astronomy +# (AURA) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. The name of AURA and its representatives may not be used to +# endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS """Common utilities used in testing""" import os +import shutil +import subprocess +import sys import fixtures import testresources @@ -51,3 +79,39 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase): self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.FakeLogger()) + self.useFixture(fixtures.EnvironmentVariable('PBR_VERSION', '0.0')) + + self.temp_dir = self.useFixture(fixtures.TempDir()).path + self.package_dir = os.path.join(self.temp_dir, 'testpackage') + shutil.copytree(os.path.join(os.path.dirname(__file__), 'testpackage'), + self.package_dir) + self.addCleanup(os.chdir, os.getcwd()) + os.chdir(self.package_dir) + + def tearDown(self): + # Remove pbr.testpackage from sys.modules so that it can be freshly + # re-imported by the next test + for k in list(sys.modules): + if (k == 'pbr_testpackage' or + k.startswith('pbr_testpackage.')): + del sys.modules[k] + super(BaseTestCase, self).tearDown() + + def run_setup(self, *args): + return self._run_cmd(sys.executable, ('setup.py',) + 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 + working copy--returns the stdout and stderr streams and the exit code + from the subprocess. + """ + + os.chdir(self.package_dir) + p = subprocess.Popen([cmd] + list(args), stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + streams = tuple(s.decode('latin1').strip() for s in p.communicate()) + print(streams) + return (streams) + (p.returncode,) diff --git a/pbr/d2to1/tests/test_commands.py b/pbr/tests/test_commands.py index 6dbbd3c..f5831fa 100644 --- a/pbr/d2to1/tests/test_commands.py +++ b/pbr/tests/test_commands.py @@ -40,10 +40,10 @@ from testtools import content -from pbr.d2to1 import tests +from pbr import tests -class TestCommands(tests.D2to1TestCase): +class TestCommands(tests.BaseTestCase): def test_custom_build_py_command(self): """Test custom build_py command. diff --git a/pbr/d2to1/tests/test_core.py b/pbr/tests/test_core.py index 092eca8..4b6c49b 100644 --- a/pbr/d2to1/tests/test_core.py +++ b/pbr/tests/test_core.py @@ -42,10 +42,12 @@ import glob import os import tarfile -from pbr.d2to1 import tests +import fixtures +from pbr import tests -class TestCore(tests.D2to1TestCase): + +class TestCore(tests.BaseTestCase): def test_setup_py_keywords(self): """setup.py --keywords. @@ -73,3 +75,26 @@ class TestCore(tests.D2to1TestCase): 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) diff --git a/pbr/d2to1/tests/test_hooks.py b/pbr/tests/test_hooks.py index a9e9864..88106a6 100644 --- a/pbr/d2to1/tests/test_hooks.py +++ b/pbr/tests/test_hooks.py @@ -41,22 +41,22 @@ import os import textwrap -from pbr.d2to1 import tests -from pbr.d2to1.tests import util +from pbr import tests +from pbr.tests import util -class TestHooks(tests.D2to1TestCase): +class TestHooks(tests.BaseTestCase): def setUp(self): super(TestHooks, self).setUp() with util.open_config( os.path.join(self.package_dir, 'setup.cfg')) as cfg: cfg.set('global', 'setup-hooks', - 'd2to1_testpackage._setup_hooks.test_hook_1\n' - 'd2to1_testpackage._setup_hooks.test_hook_2') + 'pbr_testpackage._setup_hooks.test_hook_1\n' + 'pbr_testpackage._setup_hooks.test_hook_2') cfg.set('build_ext', 'pre-hook.test_pre_hook', - 'd2to1_testpackage._setup_hooks.test_pre_hook') + 'pbr_testpackage._setup_hooks.test_pre_hook') cfg.set('build_ext', 'post-hook.test_post_hook', - 'd2to1_testpackage._setup_hooks.test_post_hook') + 'pbr_testpackage._setup_hooks.test_post_hook') def test_global_setup_hooks(self): """Test setup_hooks. @@ -84,10 +84,8 @@ class TestHooks(tests.D2to1TestCase): stdout, _, return_code = self.run_setup('build_ext') assert textwrap.dedent(""" running build_ext - running pre_hook d2to1_testpackage._setup_hooks.test_pre_hook for command build_ext + running pre_hook pbr_testpackage._setup_hooks.test_pre_hook for command build_ext build_ext pre-hook """) in stdout # flake8: noqa assert stdout.endswith('build_ext post-hook') assert return_code == 0 - - diff --git a/pbr/d2to1/tests/testpackage/CHANGES.txt b/pbr/tests/testpackage/CHANGES.txt index 709b9d4..709b9d4 100644 --- a/pbr/d2to1/tests/testpackage/CHANGES.txt +++ b/pbr/tests/testpackage/CHANGES.txt diff --git a/pbr/d2to1/tests/testpackage/LICENSE.txt b/pbr/tests/testpackage/LICENSE.txt index 7e8019a..7e8019a 100644 --- a/pbr/d2to1/tests/testpackage/LICENSE.txt +++ b/pbr/tests/testpackage/LICENSE.txt diff --git a/pbr/d2to1/tests/testpackage/MANIFEST.in b/pbr/tests/testpackage/MANIFEST.in index cdc95ea..cdc95ea 100644 --- a/pbr/d2to1/tests/testpackage/MANIFEST.in +++ b/pbr/tests/testpackage/MANIFEST.in diff --git a/pbr/d2to1/tests/testpackage/README.txt b/pbr/tests/testpackage/README.txt index 4f00d32..b6d84a7 100644 --- a/pbr/d2to1/tests/testpackage/README.txt +++ b/pbr/tests/testpackage/README.txt @@ -5,7 +5,7 @@ projects; specifically those projects that comprise stsci_python_ and Astrolib_. It currently consists mostly of some setup_hook scripts meant for use with -`distutils2/packaging`_ and/or d2to1_, and a customized easy_install command +`distutils2/packaging`_ and/or pbr_, and a customized easy_install command meant for use with distribute_. This package is not meant for general consumption, though it might be worth diff --git a/pbr/d2to1/tests/testpackage/data_files/a.txt b/pbr/tests/testpackage/data_files/a.txt index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/data_files/a.txt +++ b/pbr/tests/testpackage/data_files/a.txt diff --git a/pbr/d2to1/tests/testpackage/data_files/b.txt b/pbr/tests/testpackage/data_files/b.txt index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/data_files/b.txt +++ b/pbr/tests/testpackage/data_files/b.txt diff --git a/pbr/d2to1/tests/testpackage/data_files/c.rst b/pbr/tests/testpackage/data_files/c.rst index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/data_files/c.rst +++ b/pbr/tests/testpackage/data_files/c.rst diff --git a/pbr/d2to1/tests/testpackage/extra-file.txt b/pbr/tests/testpackage/extra-file.txt index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/extra-file.txt +++ b/pbr/tests/testpackage/extra-file.txt diff --git a/pbr/d2to1/__init__.py b/pbr/tests/testpackage/pbr_testpackage/__init__.py index e69de29..e69de29 100644 --- a/pbr/d2to1/__init__.py +++ b/pbr/tests/testpackage/pbr_testpackage/__init__.py diff --git a/pbr/d2to1/tests/testpackage/d2to1_testpackage/_setup_hooks.py b/pbr/tests/testpackage/pbr_testpackage/_setup_hooks.py index f8b3087..f8b3087 100644 --- a/pbr/d2to1/tests/testpackage/d2to1_testpackage/_setup_hooks.py +++ b/pbr/tests/testpackage/pbr_testpackage/_setup_hooks.py 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/d2to1/tests/testpackage/d2to1_testpackage/package_data/1.txt b/pbr/tests/testpackage/pbr_testpackage/package_data/1.txt index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/d2to1_testpackage/package_data/1.txt +++ b/pbr/tests/testpackage/pbr_testpackage/package_data/1.txt diff --git a/pbr/d2to1/tests/testpackage/d2to1_testpackage/package_data/2.txt b/pbr/tests/testpackage/pbr_testpackage/package_data/2.txt index e69de29..e69de29 100644 --- a/pbr/d2to1/tests/testpackage/d2to1_testpackage/package_data/2.txt +++ b/pbr/tests/testpackage/pbr_testpackage/package_data/2.txt diff --git a/pbr/d2to1/tests/testpackage/setup.cfg b/pbr/tests/testpackage/setup.cfg index a200616..9bcc0ee 100644 --- a/pbr/d2to1/tests/testpackage/setup.cfg +++ b/pbr/tests/testpackage/setup.cfg @@ -1,10 +1,10 @@ [metadata] -name = d2to1_testpackage +name = pbr_testpackage version = 0.1.dev -author = Erik M. Bray -author-email = embray@stsci.edu -home-page = http://www.stsci.edu/resources/software_hardware/stsci_python -summary = Test package for testing d2to1 +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://pypi.python.org/pypi/pbr +summary = Test package for testing pbr description-file = README.txt CHANGES.txt @@ -26,21 +26,25 @@ classifier = keywords = packaging, distutils, setuptools [files] -packages = d2to1_testpackage +packages = pbr_testpackage package-data = testpackage = package_data/*.txt data-files = testpackage/data_files = data_files/*.txt extra-files = extra-file.txt -[extension=d2to1_testpackage.testext] +[entry_points] +console_scripts = + pbr_test_cmd = pbr_testpackage.cmd:main + +[extension=pbr_testpackage.testext] sources = src/testext.c optional = True [global] #setup-hooks = -# d2to1_testpackage._setup_hooks.test_hook_1 -# d2to1_testpackage._setup_hooks.test_hook_2 -commands = d2to1_testpackage._setup_hooks.test_command +# pbr_testpackage._setup_hooks.test_hook_1 +# pbr_testpackage._setup_hooks.test_hook_2 +commands = pbr_testpackage._setup_hooks.test_command [build_ext] -#pre-hook.test_pre_hook = d2to1_testpackage._setup_hooks.test_pre_hook -#post-hook.test_post_hook = d2to1_testpackage._setup_hooks.test_post_hook +#pre-hook.test_pre_hook = pbr_testpackage._setup_hooks.test_pre_hook +#post-hook.test_post_hook = pbr_testpackage._setup_hooks.test_post_hook diff --git a/pbr/d2to1/tests/testpackage/setup.py b/pbr/tests/testpackage/setup.py index 8866691..8866691 100755 --- a/pbr/d2to1/tests/testpackage/setup.py +++ b/pbr/tests/testpackage/setup.py diff --git a/pbr/d2to1/tests/testpackage/src/testext.c b/pbr/tests/testpackage/src/testext.c index 872d43c..872d43c 100644 --- a/pbr/d2to1/tests/testpackage/src/testext.c +++ b/pbr/tests/testpackage/src/testext.c diff --git a/pbr/d2to1/tests/util.py b/pbr/tests/util.py index e657508..e657508 100644 --- a/pbr/d2to1/tests/util.py +++ b/pbr/tests/util.py diff --git a/pbr/d2to1/util.py b/pbr/util.py index 583c6b8..3faa58e 100644 --- a/pbr/d2to1/util.py +++ b/pbr/util.py @@ -77,6 +77,7 @@ try: except ImportError: import ConfigParser as configparser +import pbr.hooks # A simplified RE for this; just checks that the line ends with version # predicates in () @@ -219,7 +220,9 @@ def cfg_to_args(path='setup.cfg'): try: if setup_hooks: - setup_hooks = split_multiline(setup_hooks) + setup_hooks = [ + hook for hook in split_multiline(setup_hooks) + if hook != 'pbr.hook.setup_hook'] for hook in setup_hooks: hook_fn = resolve_name(hook) try : @@ -233,8 +236,15 @@ def cfg_to_args(path='setup.cfg'): log.error(traceback.format_exc()) sys.exit(1) + # Run the pbr hook + pbr.hooks.setup_hook(config) + kwargs = setup_cfg_to_setup_kwargs(config) + # Set default config overrides + kwargs['include_package_data'] = True + kwargs['zip_safe'] = False + register_custom_compilers(config) ext_modules = get_extension_modules(config) @@ -261,7 +271,7 @@ def cfg_to_args(path='setup.cfg'): # monkey-patch the manifest_maker class @monkeypatch_method(manifest_maker) def add_defaults(self, extra_files=extra_files, log=log): - log.info('[d2to1] running patched manifest_maker command ' + log.info('[pbr] running patched manifest_maker command ' 'with extra_files support') add_defaults._orig(self) self.filelist.extend(extra_files) @@ -16,7 +16,7 @@ import setuptools -from pbr.d2to1 import util +from pbr import util setuptools.setup( **util.cfg_to_args()) 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 d4fafa5..1e42aff 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,7 +45,7 @@ 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 @@ -87,9 +87,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 @@ -151,7 +194,7 @@ for PROJECT in $PROJECTS ; do # TODO(mordred): need to implement egg filtering # Because install will have caused eggs to be locally downloaded - # pbr and d2to1 can get excluded from being in the actual venv + # pbr can get excluded from being in the actual venv # test that this did not happen # $tempvenv/bin/python -c 'import pkg_resources as p; import sys; pbr=p.working_set.find(p.Requirement.parse("pbr")) is None; sys.exit(pbr or 0)' done @@ -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 |