summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-07-27 14:42:36 +0000
committerGerrit Code Review <review@openstack.org>2013-07-27 14:42:36 +0000
commit9e3af631e02251cb4c156f470e1deecacf9879e0 (patch)
tree3f20b664a9e82ea2c3839f0fe6d3be18a5abfd64
parent37f5b545aebf9ddeaf005c5718d77c31dd81032f (diff)
parent8a43c13bdcf74c198a8330bb4e44f7853ec1c2b6 (diff)
downloadpbr-9e3af631e02251cb4c156f470e1deecacf9879e0.tar.gz
Merge "Also patch easy_install script creation"
-rw-r--r--pbr/hooks/commands.py4
-rw-r--r--pbr/packaging.py5
-rw-r--r--pbr/tests/test_core.py24
3 files changed, 31 insertions, 2 deletions
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/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/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)