This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make install DESTDIR=/home/blah fails when the prefix specified is /
Type: behavior Stage: resolved
Components: Distutils, Distutils2 Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7, 3rd party
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: Arfrever, George.Peristerakis, Ivailo.Monev, alexis, anacrolix, anal.phabet, eric.araujo, mailtome, mro, r.david.murray, rpetrov, tarek, xdegaye
Priority: normal Keywords: patch

Created on 2010-08-24 19:19 by mailtome, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-destdir.patch mailtome, 2010-08-24 19:19
fix-root-prefix.patch anacrolix, 2011-06-14 05:37
issue9674.patch George.Peristerakis, 2012-10-29 03:36 review
issue9674.patch George.Peristerakis, 2012-11-03 22:03 review
issue9674-2.patch Ivailo.Monev, 2015-02-13 11:03 Updated versin of the patch by George Peristerakis so it applies on Python 2.7.9, not tested on Python 3.x
Python-3.4.3-issue9674-3.patch mro, 2015-05-29 11:05 Ivailo's 2.7.9 patch ported to 3.4.3
Messages (20)
msg114804 - (view) Author: aj (mailtome) Date: 2010-08-24 19:19
I tried to install python with make install DESTDIR=/home/blah 
./python -E ./setup.py install \ 
                --prefix=/ \ 
                --install-scripts=//bin \ 
                --install-platlib=//lib/python2.6/lib-dynload \ 
                --root=//home/blah 
running install 
running build 
running build_ext 
INFO: Can't locate Tcl/Tk libs and/or headers 
Failed to find the necessary bits to build these modules: 
_tkinter           bsddb185           dl 
imageop            sunaudiodev 
To find the necessary bits, look in setup.py in detect_modules() for 
the module's name. 
running build_scripts 
running install_lib 
creating /lib/python2.6 
error: could not create '/lib/python2.6': Permission denied 
make: *** [sharedinstall] Error 1 

I asked for help on the mailing list http://groups.google.com/group/comp.lang.python/browse_thread/thread/a0b0e49f7b8153d1#, and according to Martin v. Loewis  	
"If you have / as the prefix, you get two leading slashes, e.g. for 
//lib/python2.x. Any other prefix would have given you only a single 
slash: e.g. if it had been /usr, then you end up with /usr/lib/python2.x. 
Now, the code strips the first character to make it a relative path name 
(so that join can be used), which fails to work correctly if there are 
two leading slashes. "

I have attached the patch provided by him.
msg114851 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-24 23:37
Thank you for the report. I’m not sure I understand the bug.

1) On my linux-based system, doing something on //dir is the same thing as /dir. Is this a cosmetic bug (IOW, you’d like to see /dir and not //dir)?

2) Since I’m not root, creating /lib/python2.6 fails, as it should. (Note that distutils only prints one slash, which is nice.) What is the bug?

3) It’s not clear in your past whether you ran with DESTDIR=/ or  DESTDIR=/home/blah. Can you tell what you want to do and what is the bug?

Thanks again for the report.
msg114853 - (view) Author: aj (mailtome) Date: 2010-08-25 00:13
I ran
./configure --prefix=/
make
make install DESTDIR=/home/blah 
The installation tries to install at /lib/python2.6 which fails because I am not root. It should not try to install anything at / because I specified DESTDIR as /home/blah.
msg114854 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-25 00:24
Thanks for the clarification. Can you test the bug with the versions that are still open for bug fixes, that is 2.7, 3.1 and 3.2?

I’ll add tests and apply the original patch in distutils2. (distutils is frozen except for bug fixes, which this minor cosmetic change is not.)

I’m not a configure or make expert, so I’ll request help from other developers when we have more information.
msg114857 - (view) Author: aj (mailtome) Date: 2010-08-25 00:44
Thanks for the reply Eric. It is not a cosmetic thing. It's a bug for sure in python-2.6 disutils. I will try out python-2.7, 3.1, 3.2 and update the bug.
msg114861 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-25 00:57
I have no certitude, but a strong intuition that distutils is not guilty at all here, but the makefile is. When I talk about the cosmetic bug, I refer to the double slash thing.
msg114903 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-25 13:33
See also issue1676135.  Seems that the posters were wrong in concluding that the double slashes wouldn't bother anyone using prefix=/ :)
msg117679 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-30 00:25
Re-adding distutils since we’re not sure the bug does not apply there.

aj, have you add time to test it?
msg138291 - (view) Author: Matt Joiner (anacrolix) Date: 2011-06-14 05:08
Just ran into this bug myself with 3.2. Apparently this patch works: http://groups.google.com/group/comp.lang.python/msg/bd8818ab9d4af8d7
msg138292 - (view) Author: Matt Joiner (anacrolix) Date: 2011-06-14 05:37
Attached a patch that fixes it, only the line numbers have changed from Martin v. Loewis's patch. Used on 3.2.
msg138374 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-15 14:23
Thanks.  Have you run the test suite to make sure this doesn’t add bugs?
msg171571 - (view) Author: Ron Hubbard (anal.phabet) Date: 2012-09-29 13:28
this is a very ugly bug and should be fixed ASAP

it's not only breaking python itself, but any package that uses this python installer, for example

http://seclists.org/nmap-dev/2012/q3/1025

what is preventing a merge of the existing patch ?
msg171663 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-09-30 19:45
A unit test is needed.
msg174101 - (view) Author: George Peristerakis (George.Peristerakis) Date: 2012-10-29 03:36
Here's a patch to the problem. I refactored the code to work the same way on posix, nt, os2 environments. Plus a unit test for the posix environment that the bug was initially for.
msg174710 - (view) Author: George Peristerakis (George.Peristerakis) Date: 2012-11-03 22:03
Correction a typo error in the test.
msg176820 - (view) Author: Ron Hubbard (anal.phabet) Date: 2012-12-03 00:13
George.Peristerakis' patch works

please apply
msg235887 - (view) Author: Ivailo Monev (Ivailo.Monev) Date: 2015-02-13 11:03
Can you please apply fix-root-prefix.patch? Or the updated version fof issue9674.patch that I've attached?

sysconfig tests will still fail and it will return bogus paths with double slash (e.g. //lib/python2.7) but at least Python will be installable with prefix=/ and will not mess up with files on root (/) when DESTDIR is set. That may not be complete solution but it's a step forward to that.
msg244367 - (view) Author: Martin Olsen (mro) Date: 2015-05-29 11:05
I have python (2.7.9 & 3.4.3) installed with prefix=/ which causes problems when change_root() doesn't lstrip() the path separators.

I have applied Ivailo's patch from 2015-02-13 and handful of packages without issues.

Attached is a port of the patch to 3.4.3. Please note that the test failed (because it used the old distutils package, I suspect) and the win32 path handling is a bit messed up, but I don't have time to fix that ATM. It works as expected during runtime.
msg299780 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2017-08-05 13:10
Issue 31114 is the same issue and proposes a workaround and another fix.
msg305364 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2017-11-01 10:03
The problem is that the build system , Py_GetPath() and the distutils module do not handle correctly the case where the configure prefix is '/'.

Closing as a duplicate of issue 31114.
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53883
2017-11-01 10:03:59xdegayesetstatus: open -> closed
resolution: duplicate
messages: + msg305364

stage: test needed -> resolved
2017-08-05 13:10:18xdegayesetnosy: + xdegaye
messages: + msg299780
2015-05-29 11:05:14mrosetfiles: + Python-3.4.3-issue9674-3.patch
nosy: + mro
messages: + msg244367

2015-02-13 11:03:36Ivailo.Monevsetfiles: + issue9674-2.patch
nosy: + Ivailo.Monev
messages: + msg235887

2015-02-13 08:33:21ned.deilylinkissue23435 superseder
2012-12-03 07:52:30Arfreversetnosy: + Arfrever
2012-12-03 00:13:55anal.phabetsetmessages: + msg176820
2012-11-03 22:03:05George.Peristerakissetfiles: + issue9674.patch

messages: + msg174710
2012-10-29 03:36:02George.Peristerakissetfiles: + issue9674.patch
nosy: + George.Peristerakis
messages: + msg174101

2012-09-30 19:45:54eric.araujosetmessages: + msg171663
versions: + Python 3.4
2012-09-29 13:28:25anal.phabetsetmessages: + msg171571
2012-09-28 16:33:09eric.araujosetnosy: + anal.phabet
2012-09-28 16:32:46eric.araujolinkissue16065 superseder
2011-06-15 14:23:33eric.araujosetversions: + Python 3.3, - Python 3.1
messages: + msg138374

assignee: tarek -> eric.araujo
components: - Build, Installation, Library (Lib)
type: compile error -> behavior
stage: test needed
2011-06-14 05:38:29anacrolixsetnosy: + alexis
type: behavior -> compile error
components: + Build, Library (Lib)
2011-06-14 05:37:15anacrolixsetfiles: + fix-root-prefix.patch

messages: + msg138292
2011-06-14 05:08:52anacrolixsetnosy: + anacrolix
messages: + msg138291
2010-09-30 00:25:05eric.araujosetversions: + 3rd party
nosy: tarek, eric.araujo, rpetrov, r.david.murray, mailtome
messages: + msg117679

assignee: tarek
components: + Distutils
2010-08-25 15:35:26rpetrovsetnosy: + rpetrov
2010-08-25 13:33:26r.david.murraysetnosy: + r.david.murray
messages: + msg114903
2010-08-25 00:57:37eric.araujosetmessages: + msg114861
2010-08-25 00:44:56mailtomesetmessages: + msg114857
2010-08-25 00:24:27eric.araujosetassignee: tarek -> (no value)
messages: + msg114854
components: - Distutils
nosy: tarek, eric.araujo, mailtome
2010-08-25 00:15:14mailtomesettitle: make install DESTDIR=/ fails -> make install DESTDIR=/home/blah fails when the prefix specified is /
2010-08-25 00:14:00mailtomesetmessages: + msg114853
2010-08-24 23:37:20eric.araujosetassignee: tarek
type: compile error -> behavior
components: + Distutils, Distutils2
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
nosy: + eric.araujo, tarek

messages: + msg114851
2010-08-24 19:19:45mailtomecreate