[Distutils] Correct way to allow C extension building to fail?

Andrew Straw strawman at astraw.com
Thu Jul 3 00:07:00 CEST 2008

Sorry, I was thinking to switch the return value of the distclass's
has_ext_modules() method based on whether building the extension failed
(not in all cases). Sorry for not being more clear. Anyhow, it's just an
idea -- I have no idea when setuptools queries this method relative to
when compiling the modules actually take place.

If switching after the build failed isn't possible, I wonder if you
could semi-reliably predict whether the build would fail (compiler
detection?) and then switch the distclass based on that? I realize that
idea is sub-optimal...

Maybe what you want to do is too magic anyway -- perhaps the users
should just attempt to install the version with extension code and if
that fails to install the version with no extension code? Or maybe the
extension code is a 2nd package that the main package works around if it
cannot be imported?


Andreas Klöckner wrote:
> Hi Andrew,
> On Mittwoch 02 Juli 2008, Andrew Straw wrote:
>> I'm not sure if this will work, but it might:
>> class NotPlatformDependentDistribution(Distribution):
>>     # Force platform-independent build.
>>     def has_ext_modules(self):
>>         return False
>> setup(
>>       distclass = NotPlatformDependentDistribution,
>>       )
> First of all, thanks for your help. However, when I try your solution, it 
> seems to disable the C extension outright, which is not what I'm going for. 
> Instead, I would like setuptools to try the build and simply forget about it 
> if it fails.
> Can that be done somehow?
> Thanks,
> Andreas
> ------------------------------------------------------------------------
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

More information about the Distutils-SIG mailing list