Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 240149 - dev-lang/python-2.6: execprefix has double-slash => all distutils ebuilds fail
Summary: dev-lang/python-2.6: execprefix has double-slash => all distutils ebuilds fail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 240530 (view as bug list)
Depends on:
Blocks: python-2.6
  Show dependency tree
 
Reported: 2008-10-05 21:05 UTC by Steven Robertson
Modified: 2008-10-25 15:08 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Robertson 2008-10-05 21:05:59 UTC
Hi,

I can't install any distutils-based packages; they all keep trying to write outside of the image directory, causing sandbox to kill them.  The cause is a bit of a snowball: while portage correctly passes the --root= option to the distutils-based ./setup.py, distutils ignores it.  The reason for that is in the last of lines (python-2.6/distutils/util.py):

    if os.name == 'posix':
        if not os.path.isabs(pathname):
            return os.path.join(new_root, pathname)
        else:
            return os.path.join(new_root, pathname[1:])

It's failing, as it turns out, because 

$ python -c 'import sys; print sys.exec_prefix'
//usr

Why 'exec_prefix' has a double-slash, I haven't yet figured out, but it does.  distutils *does* run exec_prefix through os.path.normpath(), but (python-2.6/posixpath.py):

    # POSIX allows one or two initial slashes, but treats three or more
    # as single slash.

Meaning that the second arg to os.path.join() above begins with '/usr', which is absolute, so it discards the value of --root.

In my eyes, the best fix is an upstream patch to distutils which lets it handle the particular case of paths with a double-slash in front, but since this issue might affect Gentooers before most others I wanted to post here first.  For now, I fixed it by changing the offending line from utils.py to


            return os.path.join(new_root, pathname.lstrip('/'))

HTH,
Steven
Comment 1 Steven Robertson 2008-10-05 21:31:03 UTC
Aha.

$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 19 2008-10-05 18:56 /usr/bin/python -> //usr/bin/python2.6

# eselect python set 1
# eselect python set 2
# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 18 2008-10-05 21:28 /usr/bin/python -> /usr/bin/python2.6

...not sure why, but when the ebuild installed, it added an extra slash to the linked path. manually eselecting the old python then the new one again installed a correct link.
Comment 2 Craig Andrews gentoo-dev 2008-10-08 21:17:30 UTC
*** Bug 240530 has been marked as a duplicate of this bug. ***
Comment 3 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2008-10-14 11:38:00 UTC
(In reply to comment #1)
> $ ls -l /usr/bin/python
> lrwxrwxrwx 1 root root 19 2008-10-05 18:56 /usr/bin/python ->
> //usr/bin/python2.6
> 
> # eselect python set 1
> # eselect python set 2
> # ls -l /usr/bin/python
> lrwxrwxrwx 1 root root 18 2008-10-05 21:28 /usr/bin/python ->
> /usr/bin/python2.6
> 
> ...not sure why, but when the ebuild installed, it added an extra slash to the
> linked path. manually eselecting the old python then the new one again
> installed a correct link.

python.eselect contains INTERPRETER_PATH="${ROOT}/usr/bin/". ROOT is set to "/" during emerging, but is usually unset in normal shell sessions.

--- python.eselect
+++ python.eselect
@@ -8,6 +8,7 @@
 VERSION=$(svn_date_to_version "${SVN_DATE}" )
 
-INTERPRETER_PATH="${ROOT}/usr/bin/"
-MAN_PATH="${ROOT}/usr/share/man/man1/"
+[[ "${ROOT}" != */ ]] && ROOT="${ROOT}/"
+INTERPRETER_PATH="${ROOT}usr/bin/"
+MAN_PATH="${ROOT}usr/share/man/man1/"
 
 # find a list of python versions
@@ -166,5 +167,5 @@
         done
 
-        if [[ -L "${ROOT}/usr/bin/python" ]]; then
+        if [[ -L "${ROOT}usr/bin/python" ]]; then
                 ${if_unset} && return
         fi
Comment 4 Elias Pipping 2008-10-20 06:54:06 UTC
How about

  if [[ -L "${ROOT%/}/usr/bin/python" ]]; then

that allows for both "" and "/".
Comment 5 Ali Polatel (RETIRED) gentoo-dev 2008-10-25 15:08:39 UTC
eselect-python-20080925 fixes this issue.
python-2.6-r3 depends on it.
Thanks everyone :)