python-packaging.html will result in incorrect #! lines for Python 3

Bug #1047457 reported by Colin Watson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Packaging Guide
Fix Released
Undecided
Dmitry Shachnev

Bug Description

The advice in python-packaging.html:

PYTHON3=$(shell py3versions -r)

...

    set -ex; for python in $(PYTHON3); do \
        $$python setup.py build; \
    done

...

    set -ex; for python in $(PYTHON3); do \
        $$python setup.py install --install-layout=deb --root=debian/tmp; \
    done

... will result in incorrect #! lines for applications defaulting to Python 3, something like #! /usr/bin/python3.2 rather than #! /usr/bin/python3. To avoid that, you need something like this:

  https://bazaar.launchpad.net/~ubuntu-core-dev/software-properties/main/revision/794

This only really matters if you're defaulting to Python 3, which probably isn't the case in the example given in this documentation since it runs the standard dh_auto_* commands *after* the manual additions and those commands will overwrite #! with #! /usr/bin/python. However, these overrides are likely to be copied and pasted with modifications, so it's worth getting them pedantically right.

Related branches

Changed in ubuntu-packaging-guide:
assignee: nobody → Dmitry Shachnev (mitya57)
status: New → In Progress
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I hope it's OK now:

=== modified file 'ubuntu-packaging-guide/python-packaging.rst'
--- ubuntu-packaging-guide/python-packaging.rst 2012-08-23 11:29:49 +0000
+++ ubuntu-packaging-guide/python-packaging.rst 2012-09-07 16:12:04 +0000
@@ -37,8 +37,12 @@

 .. code-block:: makefile

- # This command builds the list of supported Python 3 versions
- PYTHON3=$(shell py3versions -r)
+ # These command build the list of supported Python 3 versions
+ # The last version should be just "python3" so that the scripts
+ # get a correct shebang.
+ PY3REQUESTED := $(shell py3versions -r)
+ PY3DEFAULT := $(shell py3versions -d)
+ PYTHON3 := $(filter-out $(PY3DEFAULT),$(PY3REQUESTED)) python3

    %:
        # Adding the required helpers

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

BTW, the Makefile highlighting is completely broken now because of https://bitbucket.org/birkenfeld/pygments-main/issue/798/coloring-makefile-assignments-incorrectly.

Revision history for this message
Colin Watson (cjwatson) wrote : Re: [Bug 1047457] Re: python-packaging.html will result in incorrect #! lines for Python 3

Yes, that looks fine.

Changed in ubuntu-packaging-guide:
status: In Progress → Fix Committed
Changed in ubuntu-packaging-guide:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.