[Pythonmac-SIG] Module build fails because distutils adds "-isysroot"

Ronald Oussoren ronaldoussoren at mac.com
Sun Oct 4 21:22:52 CEST 2009


On 30 Sep, 2009, at 18:17, Dave Peterson wrote:

> Hi Patrick,
>
> Patrick Näf wrote:
>> ... 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.
>>
>
> The options distutils uses come from the file at <python env root>/ 
> lib/python2.5/config/Makefile.  I don't think there is any distutils  
> API provided to override/change these, just ways to append to them  
> when specifying your extension configuration.  These options are  
> used because they are the same ones used when building that Python  
> distribution.
>
> So my first suggestion is that you try redefining the -isysroot  
> option in the flags you can specify in your extension's config.   
> There is a good chance the compiler will use the last specification  
> on the line rather than doing something else when it gets two values.
>
> If that doesn't work, the only other thing I can think of is to  
> temporarily edit the config/Makefile to remove / change the  
> inclusion of the -isysroot option.

Editing the Makefile is not necessary, distutils will automaticly do  
the right thing when you add '-isysroot' to the compile arguments in  
setup.py.

It should in general never be necessary to edit the Makefile inside  
your Python installation. Please file an issue in the tracker at python.org 
  if you run into a usecase where you do have to do edit the Makefile.

BTW. I'd like to drop the usage of the 10.4u SDK for Python 2.7 and  
3.2 and use the default system headers instead (except on 10.4, where  
we have to use the SDK to enable universal builds). That annoyingly  
requires some research, it turns out that building a binary on 10.5  
with "-isysroot /" does not result in something that's fully usable on  
10.4 :-(

Ronald

>
> HTHs,
>
> -- Dave
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig



More information about the Pythonmac-SIG mailing list