classification
Title: Under Solaris, distutils doesn't include bitness in the directory name
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jcea Nosy List: eric.araujo, jcea, python-dev, tarek
Priority: normal Keywords: easy

Created on 2012-01-17 04:08 by jcea, last changed 2012-01-18 14:46 by eric.araujo. This issue is now closed.

Messages (9)
msg151427 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-01-17 04:08
When compiling modules under Solaris, distutils generates directories like "build/lib.solaris-2.10-i86pc-3.2". The "i86pc" part is the same both in 32 and 64 bits.

So when building 32 and 64 bit C code, the binaries are mixed and the best result you can get is something like:

"""
ImportError: ld.so.1: python: fatal: /home/pybsddb/build/lib.solaris-2.10-i86pc-2.7/bsddb3/_pybsddb.so: wrong ELF class: ELFCLASS64
"""

In other platforms, bitness is correctly detected and included in the directory name.

Since Solaris is explicitly managed in the sourcecode ("distutils.util.get_platform()"), adding "platform.architecture()[0]" in the directory name seems trivial.

I think this patch should be applied to 2.6 and 3.1, unless they are open only for security fixes.
msg151455 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-01-17 14:18
Proposed patch for Python 2.7:

"""
--- util.py.old 2011-12-12 01:34:04.412234183 +0100
+++ util.py     2012-01-17 15:15:23.262257886 +0100
@@ -12,6 +12,7 @@
 from distutils.spawn import spawn
 from distutils import log
 from distutils.errors import DistutilsByteCompileError
+import platform
 
 def get_platform ():
     """Return a string that identifies the current platform.  This is used
@@ -76,6 +77,7 @@
         if release[0] >= "5":           # SunOS 5 == Solaris 2
             osname = "solaris"
             release = "%d.%s" % (int(release[0]) - 3, release[2:])
+            machine += ".%s" %platform.architecture()[0]
         # fall through to standard osname-release-machine representation
     elif osname[:4] == "irix":              # could be "irix64"!
         return "%s-%s" % (osname, release)
"""

So now the directory is named like "lib.solaris-2.10-i86pc.32bit-2.7".

Please, review.

I will commit it to 2.7, 3.1, 3.2 and 3.3 in a few days.
msg151469 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-17 16:26
OK.

 from distutils.spawn import spawn
 from distutils import log
 from distutils.errors import DistutilsByteCompileError
+import platform

Please put that import higher up (with the other “import X”, before the “from X import Y”).
 
+            machine += ".%s" %platform.architecture()[0]

One space after the % operator please.

> I will commit it to 2.7, 3.1, 3.2 and 3.3 in a few days.

Not to 3.1, this is not a security issue.
msg151512 - (view) Author: Roundup Robot (python-dev) Date: 2012-01-18 03:01
New changeset 284550d0d8ae by Jesus Cea in branch '2.7':
Closes #13803: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/284550d0d8ae

New changeset eed73b16e71f by Jesus Cea in branch '3.2':
Closes #13803: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/eed73b16e71f

New changeset 8d0ccb4ad206 by Jesus Cea in branch 'default':
MERGE: Closes #13803: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/8d0ccb4ad206
msg151513 - (view) Author: Roundup Robot (python-dev) Date: 2012-01-18 03:28
New changeset 2ec4ab2a6f65 by Jesus Cea in branch '2.7':
Emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/2ec4ab2a6f65

New changeset 9d62f5aa35ff by Jesus Cea in branch '3.2':
Emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/9d62f5aa35ff

New changeset 4a6e0b6d493b by Jesus Cea in branch 'default':
MERGE: Emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/4a6e0b6d493b
msg151515 - (view) Author: Roundup Robot (python-dev) Date: 2012-01-18 03:50
New changeset 4074439c3894 by Jesus Cea in branch '2.7':
Yet another emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/4074439c3894

New changeset 37efae3bf912 by Jesus Cea in branch '3.2':
Yet another emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/37efae3bf912

New changeset afdce2e2f98d by Jesus Cea in branch 'default':
MERGE: Yet another emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/afdce2e2f98d
msg151517 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-01-18 04:00
A trivial check-in causing a nightmare at 5AM just hours before a day-long offline trip :-).

Eric, could you possibly review the committed version?. I can't use "platform.architecture()" because bootstrap issues. For instance: http://www.python.org/dev/buildbot/all/builders/x86%20OpenIndiana%202.7/builds/828/steps/compile/logs/stdio

Moreover, there are function redundancy between "distutils/util.py" and "sysconfig.py", and the return value must be consistent. This is just created issue13813.
msg151518 - (view) Author: Roundup Robot (python-dev) Date: 2012-01-18 04:05
New changeset 147ad02875fa by Jesus Cea in branch '3.2':
And yet another emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/147ad02875fa

New changeset 582274636446 by Jesus Cea in branch 'default':
MERGE: And yet another emergency fix for #13803 bootstrap issue: Under Solaris, distutils doesn't include bitness in the directory name
http://hg.python.org/cpython/rev/582274636446
msg151540 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-18 14:46
Final code looks OK to me.
History
Date User Action Args
2012-01-18 14:46:09eric.araujosettype: enhancement -> behavior
messages: + msg151540
2012-01-18 04:05:47python-devsetmessages: + msg151518
2012-01-18 04:00:14jceasetmessages: + msg151517
2012-01-18 03:50:00python-devsetmessages: + msg151515
2012-01-18 03:28:13python-devsetmessages: + msg151513
2012-01-18 03:01:39python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg151512

resolution: fixed
stage: patch review -> resolved
2012-01-17 16:26:09eric.araujosetmessages: + msg151469
versions: - Python 2.6, Python 3.1
2012-01-17 14:18:44jceasetassignee: tarek -> jcea
messages: + msg151455
stage: patch review
2012-01-17 04:08:38jceacreate