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: Python misbehaves when installed in / (patch attached)
Type: behavior Stage: resolved
Components: Build, Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: 1644987 Superseder:
Assigned To: Nosy List: chris@arachsys.com, iritkatriel, schmir
Priority: normal Keywords: patch

Created on 2007-02-06 17:08 by chris@arachsys.com, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Python-2.5.rootpath.patch chris@arachsys.com, 2007-02-06 17:08 Patch for getpath.c
Messages (7)
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.
msg407977 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-07 22:17
getpath.c has been rewritten (see Issue45582).  reduce is no longer there.
msg407979 - (view) Author: Chris Webb (chris@arachsys.com) Date: 2021-12-07 22:36
Irit Katriel <iritkatriel@gmail.com> added the comment:

> getpath.c has been rewritten (see Issue45582).  reduce is no longer there.

Gosh, this is one I originally reported back in the late 1990s and then  
again mid-2000s! I've carried a patch in my distribution to make python  
work in /bin and /lib/python for over 25 years - it'll feel like end of an  
era to finally be able to drop that local patch. Thanks!

(Presumably this will land in Python 11 rather than get backported?)

Best wishes,
Chris.
msg408015 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-08 12:52
> (Presumably this will land in Python 11 rather than get backported?)

I believe so.

> it'll feel like end of an era to finally be able to drop that local patch.

You should mark the occasion somehow, it's not everyday you say goodbye to a 25 year old patch!
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44551
2021-12-08 15:08:10chris@arachsys.comsetfiles: - paths.patch
2021-12-08 12:52:02iritkatrielsetmessages: + msg408015
2021-12-07 22:36:16chris@arachsys.comsetmessages: + msg407979
2021-12-07 22:17:00iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg407977

resolution: out of date
stage: patch review -> resolved
2014-02-03 19:44:39BreamoreBoysetnosy: - BreamoreBoy
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