Hi folks I'm currently writing a very simple Python module in C that provides an interface to libaprutil's MD5 routines. I compile my module using distutils, as per instructions in the "Building C and C++ Extensions with distutils" chapter of the official Python docs.
Since Mac OS X has libaprutil pre-installed, it seems natural that I try to use the system version of the library. My Python module's .c file therefore contains the following #include directive: #include <apr-1/apr_md5.h> Everything works fine (module compiles and I can use it) as long as I use the system version of Python (2.5.1) to compile the module. The problem is that I *really* need to build the module with Python 2.6 or newer, and this is where my trouble starts. I have Python 3.1.1 installed in /Library/Frameworks/Python, and with this version of Python my module's build fails miserably, like this: tharbad:~ patrick$ /Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1 ./setup.py build_ext --inplace running build_ext building 'aprmd5' extension gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -c aprmd5.c -o build/temp.macosx-10.3-fat-3.1/aprmd5.o aprmd5.c:43:60: aprmd5.c:43:60: error: apr-1/apr_md5.h: No such file or directory [...] The problem here is that the gcc option "-isysroot" moves the root for system includes to the SDK directory (/Developer/SDKs/MacOSX10.4u.sdk), away from the normal root (/). Unfortunately, the SDK does not contain the header <apr-1/apr_md5.h>, which causes the build to fail. Where does "-isysroot" come from? Not from my module, it's added automatically by distutils. I believe I have correctly diagnosed the problem, and I can certainly work around it *somehow* in my module, but since I am rather new to Python I have trouble deciding on a solution that is appropriate. I am therefore writing to this list, hoping someone reading this can give me some advice. 1) Is my problem a known situation for which there is a generally accepted, best-practice solution? If so, a pointer in the right direction would be most welcome. If not, what would seem to be a good solution? Make my own build of libaprutil using the MacOSX10.4u SDK? Rely on a third-party build of libaprutil (e.g. fink)? Force the compiler to use the system's libaprutil? 2) Is this a bug in the MacOSX10.4u SDK, i.e. should the SDK contain the headers for libaprutil? This seems possible to me, because the SDK certainly contains headers for other libraries (e.g. openssl), so why not for libaprutil? 3) Is this a bug in the Python distribution, i.e. should the Python 3.1.1 distutils *not* add "-isysroot"? I think this is not the case, distutils should add the option because Python probably was built with the SDK. 4) Is my work obsolete because someone already has written a Python module that interfaces libaprutil and has solved all of my problems? If this is so, again, pointers would be very welcome. Thanks for your time Patrick System setup: - Mac OS X 10.5.8 (includes libaprutil 1.2.7) - gcc --version: powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) - Yes, I *do* have the MacOSX10.4u SDK installed :-) - Python 3.1.1, downloaded from http://www.python.org/ftp/python/3.1.1/python-3.1.1.dmg (I have also tried Python 2.6.2 and 3.0.1, with the same result) _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig