2.6.4-0ubuntu3 distutils modification of self.prefix breaks custom install scripts

Bug #510211 reported by David Fifield
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python2.6 (Ubuntu)
Fix Released
Undecided
Matthias Klose
Karmic
Won't Fix
Undecided
Unassigned
Lucid
Fix Released
Undecided
Matthias Klose

Bug Description

Binary package hint: python2.6

The file debian/patches/distutils-install-layout.dpatch in python2.6-2.6.4-0ubuntu3 adds a special check for self.prefix == "/usr/local", and changes the value of self.prefix to "/usr" if it is so. The change that does this is http://bazaar.launchpad.net/%7Eubuntu-branches/ubuntu/karmic/python2.6/karmic-proposed/revision/38/debian/patches/distutils-install-layout.dpatch. I think this was done to fix #456917, but it has the side effect that other parts of a setup.py file that read sys.prefix will be misled.

This bug affects users who install zenmap from source. Here is a problem report we received: http://seclists.org/nmap-dev/2010/q1/91. Our setup.py script, which you can see at http://nmap.org/svn/zenmap/setup.py, uses self.prefix to do some post-install modification of installed files. The end effect is that when the user runs with --prefix=/usr/local, which is the default for our installer, files get installed in /usr/local/share/zenmap but the program looks for them in /usr/share/zenmap.

I attached a small setup.py script that demonstrates the problem. The custom installer tries to modify an installed file after the normal install process runs, and modifies the wrong file. (You have to supply a test.py script for the installer to act on.)

$ sudo python setup.py install --prefix="/usr/local"
running install
running build
running build_scripts
running install_scripts
changing mode of /usr/local/bin/test.py to 755
running install_egg_info
Removing /usr/local/lib/python2.6/dist-packages/test-1.0-py2.6.egg-info
Writing /usr/local/lib/python2.6/dist-packages/test-1.0-py2.6.egg-info
self.prefix is '/usr'
Modifying /usr/bin/test.py

This is on Ubuntu 9.10.

Related branches

Revision history for this message
David Fifield (david-bamsoftware) wrote :
Matthias Klose (doko)
Changed in python2.6 (Ubuntu):
assignee: nobody → Matthias Klose (doko)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python2.6 - 2.6.4-5ubuntu1

---------------
python2.6 (2.6.4-5ubuntu1) lucid; urgency=low

  * Merge with Debian (2.6.4-5).

python2.6 (2.6.4-5) unstable; urgency=low

  * Update to 20100131, taken from the 2.6 release branch.
    - Fix typo in os.execvp docstring. Closes: #558764.
  * distutils.sysconfig.get_python_lib(): Only return ".../dist-packages" if
    prefix is the default prefix and if PYTHONUSERBASE is not set in the
    environment and if --user option is not present. LP: #476005.
  * distutils install: Don't install into /usr/local/local, if option
    --prefix=/usr/local is present, without changing the install prefix.
    LP: #510211.
 -- Matthias Klose <email address hidden> Sun, 31 Jan 2010 22:31:41 +0100

Changed in python2.6 (Ubuntu):
status: New → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

fixed in lucid, please check. this should be a candidate for karmic after testing

Changed in python2.6 (Ubuntu Karmic):
status: New → Incomplete
Revision history for this message
David Fifield (david-bamsoftware) wrote :

I don't have lucid to test, but I backported the change from http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/lucid/python2.6/lucid/revision/42#debian/patches/distutils-install-layout.dpatch to karmic and I can confirm that it solves the problem.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Karmic has long since stopped to receive any updates. Marking the Karmic task for this ticket as "Won't Fix".

Changed in python2.6 (Ubuntu Karmic):
status: Incomplete → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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