On Oct 28, 2006, at 1:50 AM, Martin v. Löwis wrote:

Steven Bethard schrieb:
Jack Howarth asked about creating universal binaries for OS X that
would support 32-bit or 64-bit on both PPC and x86. Ronald Oussoren
pointed out that the 32-bit part of this was already supported, but
indicated that adding 64-bit support simultaneously might be more
difficult. Ronald seemed to think that modifications to pyconfig.h.in
might solve the problem, though he was worried that this might cause
distutils to detect some architecture features incorrectly.

Ronald can surely speak for himself, but I think the problem is slightly
different. There were different strategies discussed for changing
pyconfig.h (with an include, or with #ifdefs), and in all cases,
distutils would fail to detect the architecture properly. That's not
really a problem of pyconfig.h, but of the way that distutils uses
to detect bitsizes - which inherently cannot work for universal
binaries (i.e. you should look at the running interpreter, not
at pyconfig.h).

That depends on what you want to do. If you want to use the information about byteorder and bitsizes to drive the build of an extension you're better of using pyconfig.h instead of using the values of the currently running interpreter. If you want to use the information to generate raw data files in the platform byteorder and bitsizes you're better of using the struct module, so there's really no good reason to look at WORDS_BIGENDIAN and the various SIZEOF_ macros through distutils.

An example of this was the build of expat: before I merged the universal binary patches setup.py looked at sys.byteorder and then added a define to the build flags for expat. With the universal patches I changed this to an include-file that looks at the value in pyconfig.h and sets the define that expat expects. This is needed because with universal binaries the byteorder and bitsizes are no longer configure-time constants but are compile-time constants.

Note that adding support for universal builds for 32-bit architecturs was relatively easy because only one variable in pyconfig.h needed to be patched and GCC has explicit support for getting the required information.

The patch for 32-bit/64-bit builds will probably require sniffing the current architecture (e.g. "#ifdef __i386__") and settings values that way. The cleanest way to do that is in introduction of an additional include file. It also requires changes to setup.py because all mac-specific modules won't build in 64-bit code in released versions of the OS (because OSX only has a 64-bit unix-layer in 10.4, 10.5 will be 64-bit throughout).

Ronald

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to