[Pythonmac-SIG] How to build Python 2.5 to support 64-bits on Mac OS X 10.4

Dr. Harold Walter Schranz Harold.Schranz at anu.edu.au
Fri Feb 2 08:43:13 CET 2007


G'Day Gentle Programming Folk,

Thanks for the help so far ... I would appreciate any further  
comments or help.

I'm still on the quest to produce a 64 bit non-framework command-line  
version of Python 2.5 on the Mac Intel platform (e.g. Intel Core 2  
Duo and Xserve).

A little bit of non-virtuoso hand tuning ... caveat emptor ... I need  
to repeat the whole process and see if this chicken flies  
reproducibly ...

My logic (or rather a protocol plucked from the aether, enigmatic  
thus un-refutable ...) ... (this process reminds me of my ANUSF HPC  
porting days) follows below.


1. With what I thought (but the machine though otherwise) was a  
worthy combination of semi-random flags:

./configure --disable-framework --disable-toolbox-glue \
OPT="-fast -arch x86_64 \
-Wall -Wstrict-prototypes -fno-common -fPIC" \
LDFLAGS="-arch x86_64"

The make bombs finally at the posixmodule.c

gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused- 
madd -DNDEBUG -fast -arch x86_64 -Wall -Wstrict-prototypes -fno- 
common -fPIC  -I. -I./Include   -DPy_BUILD_CORE  -c ./Modules/ 
posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c: In function 'posix_setpgrp':
./Modules/posixmodule.c:3590: error: too many arguments to function  
'setpgrp'
make: *** [Modules/posixmodule.o] Error 1



2. Closer examination of posixmodule.c reveals the section of code  
around line 3590:

#ifdef HAVE_SETPGRP
PyDoc_STRVAR(posix_setpgrp__doc__,
"setpgrp()\n\n\
Make this process a session leader.");

static PyObject *
posix_setpgrp(PyObject *self, PyObject *noargs)
{
#ifdef SETPGRP_HAVE_ARG
         if (setpgrp(0, 0) < 0)                    <-- Line 3590
#else /* SETPGRP_HAVE_ARG */
         if (setpgrp() < 0)
#endif /* SETPGRP_HAVE_ARG */
                 return posix_error();
         Py_INCREF(Py_None);
         return Py_None;
}

#endif /* HAVE_SETPGRP */

In line 3590,  setpgrp(0, 0) has 2 arguments, whereas elsewhere   
setpgrp() has no arguments ...
this perhaps upsets the compiler (with the given flags, maybe there  
are looser flags?)



3. To overcome this obstacle, I tried a kludge ...

I noticed that pyconfig.h (Configuration header file) as created by  
configure (with the flags used above in step 1) had the line:

./pyconfig.h:#define SETPGRP_HAVE_ARG 1

though the pyconfig.h.in file  (Source from which pyconfig.h is  
created (GNU autoheader output)) had this feature turned off:

./pyconfig.h.in:#undef SETPGRP_HAVE_ARG

Apparently  there are two versions of setpgrp - one with arguments  
(Sys V heritage) and one without (BSD heritage)?
I think a FAQ discussion on A/UX about setpgrp might be related  
(http://www.faqs.org/faqs/aux-faq/part2/).



4. I edited pyconfig.h manually to turn off the flag SETPGRP_HAVE_ARG  
(I commented out the SETPGRP_HAVE_ARG 1 and undefined SETPGRP_HAVE_ARG)

/* Define if setpgrp() must be called as setpgrp(0, 0). */
/* #define SETPGRP_HAVE_ARG 1 */
#undef SETPGRP_HAVE_ARG


5. I the ran make which spat out a few warnings and errors: e.g.
...
In file included from /Users/harry/Desktop/TODO/Python-2.5/Modules/ 
_ctypes/_ctypes.c:110:
build/temp.macosx-10.3-i386-2.5/libffi/include/ffi.h:161: error:  
parse error before 'ffi_abi'
build/temp.macosx-10.3-i386-2.5/libffi/include/ffi.h:161: warning: no  
semicolon at end of struct or union
...
ld64 warning: in /System/Library/Frameworks//CoreFoundation.framework/ 
CoreFoundation, missing required architecture x86_64 in file
*** WARNING: renaming "_locale" since importing it failed: dlopen 
(build/lib.macosx-10.3-i386-2.5/_locale.so, 2): Symbol not found:  
_CFStringGetSystemEncoding
   Referenced from: build/lib.macosx-10.3-i386-2.5/_locale.so
   Expected in: dynamic lookup
...
ld64 warning: in /usr/lib/libsqlite3.dylib, missing required  
architecture x86_64 in file
*** WARNING: renaming "_sqlite3" since importing it failed: dlopen 
(build/lib.macosx-10.3-i386-2.5/_sqlite3.so, 2): Symbol not found:  
_sqlite3_close
   Referenced from: build/lib.macosx-10.3-i386-2.5/_sqlite3.so
   Expected in: dynamic lookup
...
ld64 warning: in /System/Library/Frameworks//Tcl.framework/Tcl,  
missing required architecture x86_64 in file
ld64 warning: in /System/Library/Frameworks//Tk.framework/Tk, missing  
required architecture x86_64 in file
*** WARNING: renaming "_tkinter" since importing it failed: dlopen 
(build/lib.macosx-10.3-i386-2.5/_tkinter.so, 2): Symbol not found:  
_Tcl_Merge
   Referenced from: build/lib.macosx-10.3-i386-2.5/_tkinter.so
   Expected in: dynamic lookup



6. However at the end of the process it appeared I had a 64-bit  
executable of Python

1714:harry at jcs156218:~/Desktop/TODO/Python-2.5:599$ file python.exe

python.exe: Mach-O 64-bit executable x86_64

1714:harry at jcs156218:~/Desktop/TODO/Python-2.5:599$ python.exe

Python 2.5 (r25:51908, Feb  2 2007, 17:12:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> 1+2
3

So it looks like it is possible to produce a Mach-O 64-bit executable  
x86_64
but whether it is working is another matter

7. Running the tests: make tests yields: in summary:

266 tests OK.
2 tests failed:
     test_cookielib test_uuid
51 tests skipped:
     test__locale test_aepack test_al test_applesingle test_bsddb
     test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn
     test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr
     test_codecmaps_tw test_ctypes test_curses test_dl test_gdbm
     test_gl test_hashlib test_hmac test_imageop test_imgfile
     test_largefile test_linuxaudiodev test_locale test_macfs
     test_macostools test_md5 test_nis test_normalization
     test_ossaudiodev test_pep247 test_pep277 test_rgbimg
     test_scriptpackages test_sha test_socket_ssl test_socketserver
     test_sqlite test_startfile test_sunaudiodev test_tcl test_timeout
     test_unicodedata test_urllib2 test_urllib2net test_urllibnet
     test_winreg test_winsound test_zipfile64
17 skips unexpected on darwin:
     test_hashlib test_bz2 test_dl test_aepack test_sha
     test_applesingle test_urllib2net test_macostools test_ctypes
     test_urllib2 test_tcl test_hmac test_pep247 test_unicodedata
     test_md5 test_scriptpackages test_macfs
make: *** [test] Error 1



I may try to repeat this process (with less flags?).
At least this run is a lead that a 64-bit build of Python is possible.

Adios
Harry.


------------------------------------------------------------------------ 
----
Dr. Harold W. Schranz, Research Fellow, Computational Genomics Group
Division of Molecular Bioscience, John Curtin School of Medical Research
Australian National University, Canberra ACT 0200, Australia
------------------------------------------------------------------------ 
----





More information about the Pythonmac-SIG mailing list