summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-07-23 15:51:40 -0700
committerMonty Taylor <mordred@inaugust.com>2013-07-23 15:59:34 -0700
commit8a43c13bdcf74c198a8330bb4e44f7853ec1c2b6 (patch)
tree5e8449d9c579a8b2b98e115dabb9a05e46a04e6f
parent24c38b34c7f7c3074aef884013a1895c01fa93e6 (diff)
downloadpbr-8a43c13bdcf74c198a8330bb4e44f7853ec1c2b6.tar.gz
Also patch easy_install script creation
During python setup.py develop, easy_install is called via a different code path to install the scripts. We need to inject into that place as well. Change-Id: Iab319f3771529c6d57f6a36ec717fb3278839f78
-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)