On 26 Apr, 2007, at 15:50, Ronald Oussoren wrote:

I know several people on this list are interested in a 64-bit build
of python. The following procedure is a hack that gets you a basic 64-
bit build of python.


The build is universal, but for me only one of the two archictures
actually worked: I did my build on an Intel system and the 64-bit
build worked on that machine, but didn't work on a G5 mac. That's
probably something shallow, but as that machine doesn't have the
Xcode installed and is on the other side of a slow network connection
I haven't tried to debug this yet.

I've installed Xcode on the PPC64 machine as well and have confirmed that the procedure below builds a 64-bit binary there as well.

The crash for the cross-compiled version is probably caused differences in pyconfig.h for the two architectures (specifically the information related to the type of va_list), although I haven't tried merging the two pyconfig.h files yet to determine if this really is the cause for the crash.

I'm starting to think about a the design for a 4-way universal Python build. My current ideas are as follows:

* The Python.framework and extensions are build 4-way universal

The extensions are build in 64-bit mode where feasable, Carbon will need to stay 32-bit only

* The 'python' and 'python2.X' commands will be 32-bit only, users will have to make an explicit decision to use 64-bit code. The commands 'python-64' and 'python2.X-64' will be 64-bit only.

There are two reasons for not letting 'python' be a 4-way universal binary. The first is that 64-bit binaries can only use unixy APIs on Tiger (or rather only libSystem, even zlib is just 32-bit), which means they are less useful than 32-bit binaries for most Mac users. The second reason is that 64-bit binaries are not necessarily the right choice even when the entire system is 64-bit capable due to additional overhead
    from the larger datatypes.

* Distutils will build 2-way universal by default when using a 32-bit python for building (that is, 'python setup.py build' will build 32-bit binaries only). A 64-bit python will build 4-way universal by default.

IMHO this is the most DWIM solution for building extensions, you'll only get 64-bit binaries when you explictly ask for it. It is also the least likely to cause problems when building extensions (a lot of build scripts would
   need patches when we'd build 64-bit by default).

Actually getting there requires some work, I don't know when I'll have time to work on this. I've only looked at a 64-bit build for python to get some simple code working with a large dataset, that code got reworked later on to use less memory and therefore we no longer have a pressing need for a 64-bit build.

The patch for distutils should be fairly trivial, the hooks to do the work should already be there as a result of the 2-way universal build machinery.

The harder part is convincing the build machinery (the configure script and Makefile's) to do the right thing.

Another non-trivial part is learning libffi about 64-bit code. That's needed to get a working version of ctypes.

The build script for the binary installer also requires changes: it would have to build the libraries it uses as 4-way universal binaries, and several more libraries would have to be added to the list if we want to have a normal stdlib for 64-bit builds.

Ronald


1) Edit the configure script, look for "-arch i386" and "-arch ppc"
and change that those to  "-arch ppc64" and "-arch x86_64". You'll
have to make multiple changes to the configure file.

2) Build using:

       $ mkdir build
       $ cd build
       $ CFLAGS="-arch ppc64 -arch x86_64" ../configure --enable-
universalsdk \
             --disable-toolbox-glue --prefix=/opt/python25-64bit
       $ make
       $ make install

3) Optionally: run "make testall" to run the unittests and check
pyconfig.h to check the various SIZEOF definitions.

You now have a 64-bit build of python in /opt/python25-64bit.

Note that this is a quick hack and I haven't done extensive testing
(and probably won't do so until I get around to working on a patch to
add native support for 4-way universal builds to the python build
process, which won't be any time soon).

Also note that several extensions won't build in this setup because
only libSystem is 64-bit at the moment. You will therefore not have
ssl support, zlib, bz2 and hashlib. If you want those you'll have to
build the needed libraries (openssl, zlib, bz2, ...) as 64-bit
binaries by hand and install those in /usr/local.

This copy of python says:

./python.exe
Python 2.5.1 (r251:54863, Apr 26 2007, 15:09:03)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.maxint
9223372036854775807


Ronald


_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

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

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to