Package: debhelper
Version: 7.4.2
Severity: normal
Tags: patch

Hi,
The commonly used package python-setuptools allows developers to specify
console scripts using the entry_points keyword argument to setup() in
setup.py. For example, an executable script named 'simplepack_pyversion'
would be created using this keyword argument:

entry_points = {'console_scripts':
  ['my_script = my_package:main']}

Unfortunately, when run with debhelper, these scripts get created with
the wrong shebang line. I am attaching a patch and a test case.

The shebang line gets assigned by setuptools as the value of
sys.executable, which is seems OK. The trouble is that debhelper
supports multiple versions of Python by cycling through those found with
"pyversions -r" starting with the default. Using this ordering scheme,
any files installed by the default Python (and thus having shebang
/usr/bin/python) get overwritten by files installed with non-default
Pythons. The attached patch replaces the order of Pythons invoked, and
thus the default Python always comes last.

The demonstration script will create a very simple package that
demonstrates the problem. Before the patch on Debian unstable, the
output of the last command in the patch is "#!/usr/bin/python2.4". With
the patch, the output of the last command is "#!/usr/bin/python".

-Andrew
>From d7dbb345f4c17aeea8fd41bdfa56440ecc1726fd Mon Sep 17 00:00:00 2001
From: Andrew Straw <straw...@astraw.com>
Date: Fri, 25 Sep 2009 18:49:51 -0700
Subject: [PATCH] fix bug with default python for setuptools entry_points console_scripts is not correct

---
 Debian/Debhelper/Buildsystem/python_distutils.pm |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem/python_distutils.pm b/Debian/Debhelper/Buildsystem/python_distutils.pm
index bc6e71f..efad08c 100644
--- a/Debian/Debhelper/Buildsystem/python_distutils.pm
+++ b/Debian/Debhelper/Buildsystem/python_distutils.pm
@@ -121,8 +121,8 @@ sub setup_py {
         $python_default =~ s/\s+$//;
         my @python_requested = split ' ', `pyversions -r 2>/dev/null`;
 	if (grep /^\Q$python_default\E/, @python_requested) {
-		@python_requested = ("python", grep(!/^\Q$python_default\E/,
-					@python_requested));
+		@python_requested = (grep(!/^\Q$python_default\E/,
+					@python_requested), "python");
 	}
 
 	my @python_dbg;
@@ -137,7 +137,7 @@ sub setup_py {
 		}
 	}
 
-	foreach my $python (@python_requested, @python_dbg) {
+	foreach my $python (@python_dbg, @python_requested) {
 		if (-x "/usr/bin/".$python) {
 			# To allow backports of debhelper we don't pass
 			# --install-layout=deb to 'setup.py install` for
-- 
1.6.2.1

Attachment: debhelper_bug_show.sh
Description: Bourne shell script

Reply via email to