pyconfig on 64-bit machines with distutils vs 32-bit legacy code

Rob Clewley rob.clewley at gmail.com
Sat Mar 21 19:58:49 EDT 2009


Hi,

I have a problem compiling legacy C code using distutils on a
colleague's 64 bit intel machine running linux. The legacy code is
linked to user-generated code from python and distutils is a
convenient platform independent way to call whatever compiler is
available to create a DLL as a python module via SWIG. My code works
fine on 32 bit machines, but on a 64 bit machine the error

/data/home/nwagner/local/lib/python2.5/pyport.h:734:2: #error
"LONG_BIT definition appears wrong for platform (bad gcc/glibc
config?)."

was generated.

I looked this error up and found it referred to a bug in python about
pyconfig.h not being automatically adaptive when mixing 32-bit code
and 64-bit libraries. There were various vague references to solutions
and a supposed fix in python, but the posts were at least a couple of
years old and didn't make a lot of sense to me. I tried adding the
'-m32' option to the gcc call using extra_compile_args but that was
not enough. According to a different suggestion on a different mailing
list, I tried replacing pyconfig.h with a version that used 32-bit
settings for the size of LONG and the other 64-bit specific sizes.
That did not help at all.

The gcc call created from my PyDSTool package's code via distutils is
(slightly reformatted for easy reading):

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPIC
-I/data/home/nwagner/local/lib/python2.5/site-packages/numpy/core/include
-I/data/home/nwagner/local/lib/python2.5/site-packages/numpy/numarray
-I/data/home/nwagner/svn/PyDSTool/PyDSTool/tests
-I/data/home/nwagner/svn/PyDSTool/PyDSTool/integrator
-I/data/home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp
-I/data/home/nwagner/local/include/python2.5
-c /data/home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp/dop853_HHnet_vf_wrap.c
-o /data/home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp/data/home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp/dop853_HHnet_vf_wrap.o
-w -m32 -D__DOPRI__

Can anyone offer any advice as to what I might be missing or
misunderstanding? I assumed it would be possible to do this
compilation even if a 64 bit version of python has been installed on
this linux box.

I'm somewhat out of my depth talking about these internal gubbins so
please go easy on me.

Thanks in advance,
Rob



More information about the Python-list mailing list