build.env-append working with merger in muniversal?

Ned Deily nad at acm.org
Tue Sep 14 12:10:14 PDT 2010


In article <1284487057.5471.1394987267 at webmail.messagingengine.com>,
 "Michael Dickens" <michaelld at macports.org> 
 wrote:
> That said, I haven't figured out how to execute Python as 32-bit to test 
> whether or not that variety works (meaning: importing as just 32-bit, since I 
> don't think OSX allows a single process to load both 32 and 64-bit 
> libraries).  From what I read, I'm supposed to be able to do:
> 
> VERSIONER_PYTHON_PREFER_32_BIT=yes python
> 
> and then whatever executable 'python' points to will be loaded as 32-bit if 
> that version is available.  My Python26 install from MacPorts is universal, 
> but it won't load as 32-bit; nor will Apple's "provided in OSX" one.  Has 
> anyone succeeded in doing this?

The VERSIONER_PYTHON_PREFER_32_BIT trick is an Apple-only feature they 
implemented in their /usr/bin/python for OS X 10.6.  It is not part of 
the standard Python distribution.   And, in the standard 2.6 
distribution, it is not easy from the command line to select which 
python arch to run.  The problem is that, in a framework build, the 
"python" executable is really just a small program (pythonw.c) that does 
an exec* of the real Python interpreter located in an app bundle located 
within the Python framework.  It does this to allow python programs to 
use OS X APIs (primarily GUI-related) that are only available to 
full-blown OS X app bundles. For MacPorts python2.6, that location is:
 
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Pyt
hon.app/

Because of the exec and 10.6 always preferring by default to execute in 
64-bit where possible, it isn't possible to override using the arch 
command.  For Python 2.7, pythonw.c (and related configure and Makefile 
options) was changed to use posix_spawn(2) instead of exec*, allowing 
control of the execution arch.  The Apple-supplied Python 2.6 was 
similarly modified (btw, their changes are available here 
http://www.opensource.apple.com/source/python/python-44.1/):

$ arch -i386 /usr/bin/python2.6 -c 'import sys;print(sys.maxsize)'
2147483647
$ arch -x86_64 /usr/bin/python2.6 -c 'import sys;print(sys.maxsize)'
9223372036854775807

That also works for 32-/64-bit python 2.7 built from souce.  It should 
work for the MacPorts python2.7 +universal with appropriate archs but I 
haven't tried it yet. 

The standard 2.6 configure and Makefile supports 32-/64- execution on OS 
X by lipo-ing the relevant Python executables into 32- and 64- bit 
versions and adding separated 'python-32' and 'python-64' commands.  The 
MacPorts portfile does not use this option.  For testing purposes it 
*may* be possible to modify the python.app's plist to specify a 32-bit 
preferred architecture but that wouldn't be a good permanent solution to 
allow user selectable architecture.   If that is needed, it would 
probably be best to backport the 2.7 "posix_spawn" changes.

-- 
 Ned Deily,
 nad at acm.org



More information about the macports-dev mailing list