classification
Title: Python misbehaves when installed in / (patch attached)
Type: behavior Stage: patch review
Components: Build, Extension Modules Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: ./configure --prefix=/ breaks, won't build C modules
View: 1644987
Superseder:
Assigned To: Nosy List: BreamoreBoy, chris@arachsys.com, schmir
Priority: normal Keywords: patch

Created on 2007-02-06 17:08 by chris@arachsys.com, last changed 2010-09-16 20:27 by BreamoreBoy.

Files
File name Uploaded Description Edit
Python-2.5.rootpath.patch chris@arachsys.com, 2007-02-06 17:08 Patch for getpath.c
paths.patch chris@arachsys.com, 2010-07-11 16:24 reduce() patch rebased to Python 2.7
Messages (4)
msg31197 - (view) Author: Chris Webb (chris@arachsys.com) Date: 2007-02-06 17:08
reduce() in getpath.c chops down a path to the empty string rather than to /. As a result, if you build python with --prefix='' in the usual way for software to be installed into /, it tries to find its libraries in the current directory instead of in /lib:

$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Python 2.5 (r25:51908, Feb  6 2007, 16:15:42) 
[GCC 3.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

This is fixed by the attached patch.

$ python
Python 2.5 (r25:51908, Feb  6 2007, 16:19:38) 
[GCC 3.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

msg109877 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-07-10 15:34
I think the patch should be looked at very carefully as I guess that the reduce function is called all over the place.
msg110024 - (view) Author: Chris Webb (chris@arachsys.com) Date: 2010-07-11 16:24
Fortunately reduce() is static within getpath.c, so it should only be
necessary to check the handful of callers in there. I've done this, and
am reasonably sure it doesn't break anything.

In addition, I've given this patch quite a bit of empirical testing, at least under linux/glibc. This has been a persistent bug in Python since
2004 or earlier, and I've needed the attached fix on our Python builds
on all our production servers since then, rebasing for every release
from 2.4 to the new 2.7. (Our machines don't have legacy /usr dirs so
Python is installed to /bin and /lib.)

The exact patch I'm using right now against 2.7 is attached, but it's
essentially identical to the one I submitted originally against Python
2.4, and later against Python 2.5.
msg116605 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-09-16 20:27
Can someone with a Linux box try the latest patch please.
History
Date User Action Args
2010-09-16 20:27:22BreamoreBoysetmessages: + msg116605
2010-07-11 16:24:15chris@arachsys.comsetfiles: + paths.patch
keywords: + patch
messages: + msg110024
2010-07-10 15:34:17BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
nosy: + BreamoreBoy

messages: + msg109877

stage: test needed -> patch review
2009-03-30 21:23:59ajaksu2setstage: test needed
dependencies: + ./configure --prefix=/ breaks, won't build C modules
type: behavior
components: + Extension Modules
versions: + Python 2.6, - Python 2.5
2008-03-14 18:51:27schmirsetnosy: + schmir
2007-02-06 17:08:40chris@arachsys.comcreate