Opened 13 years ago

Closed 13 years ago

#28703 closed defect (duplicate)

Python 2.6 (Universal) does not honor 'arch -i386' command at runtime

Reported by: tcwan (TC Wan) Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: Cc:
Port: python26

Description (last modified by jmroot (Joshua Root))

I have built Python 2.6 and 2.7 with +universal. I need to execute 32-bit Python for a specific module.

tcmac$ file /opt/local/bin/python2.*
/opt/local/bin/python2.6:        Mach-O universal binary with 2 architectures
/opt/local/bin/python2.6 (for architecture x86_64):	Mach-O 64-bit executable x86_64
/opt/local/bin/python2.6 (for architecture i386):	Mach-O executable i386
/opt/local/bin/python2.6-config: a /opt/local/Library/Frameworks/P script text executable
/opt/local/bin/python2.7:        Mach-O universal binary with 2 architectures
/opt/local/bin/python2.7 (for architecture x86_64):	Mach-O 64-bit executable x86_64
/opt/local/bin/python2.7 (for architecture i386):	Mach-O executable i386
/opt/local/bin/python2.7-config: a /opt/local/Library/Frameworks/P script text executable

However, when using the arch command to specify the runtime architecture, only Python 2.7 honors this, it does not work with Python 2.6.

tcmac$ arch -i386 /opt/local/bin/python2.6 
Python 2.6.6 (r266:84292, Mar  4 2011, 09:28:43) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.maxsize
9223372036854775807
>>> 
tcmac$ arch -i386 /opt/local/bin/python2.7 
Python 2.7.1 (r271:86832, Mar  1 2011, 09:22:53) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.maxsize
2147483647
>>> 

Change History (5)

comment:1 Changed 13 years ago by jmroot (Joshua Root)

Description: modified (diff)
Owner: changed from macports-tickets@… to mcalhoun@…
Port: python26 added

Please remember to preview and use WikiFormatting, fill in the Port field, and cc the maintainer.

This isn't a problem specific to the port; the official binaries behave the same. So I doubt it's going to be fixed. Run python like this: arch -i386 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

comment:2 Changed 13 years ago by tcwan (TC Wan)

I apologize for the issues. For system python, it works if the specific version is used.

tcmac$  ll /usr/bin/python2.6

lrwxr-xr-x  1 root  wheel  75 Jun 22  2010 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6


tcmac$ arch -i386 /usr/bin/python2.6
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.maxsize
2147483647

Is there any reason why this behaves differently for MacPorts between Python 2.6 and 2.7 when they are both setup similarly?

tcmac$ ll /opt/local/bin/python2.?
lrwxr-xr-x  1 root  wheel  73 Mar  4 09:34 /opt/local/bin/python2.6 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x  1 root  wheel  73 Mar  1 09:29 /opt/local/bin/python2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

comment:3 Changed 13 years ago by jmroot (Joshua Root)

Upstream probably did something about it for 2.7. Apple has a pile of changes that they apply to the python they ship, including support for VERSIONER_PYTHON_PREFER_32_BIT and so on.

comment:4 Changed 13 years ago by blb@…

Probably a dup of #22367 (which mentions the upstream bug where the "arch -386" was fixed for 2.7 but not 2.6).

comment:5 Changed 13 years ago by jmroot (Joshua Root)

Resolution: duplicate
Status: newclosed

Agreed.

Note: See TracTickets for help on using tickets.