[Distutils] C extension modules

Floris Bruynooghe floris.bruynooghe at gmail.com
Tue Jan 26 18:46:43 CET 2010


Hi Torsten

On Mon, Jan 25, 2010 at 11:22:17PM +0100, Torsten Mohr wrote:
> i'm not sure if this is the preferred way to get help.  If it is
> not, can you then please tell me how?

This is the right place, comp.lang.python might work too.

> I write a C++ extension module in which i need to tell if i compile on Linux 
> or Windows.  What is the preferred way to do this?

Use one of platform.system() or sys.platform, depending on the lowest
verion of python you want to support.

> Also, i use libjpeg, libtiff and libpng.  Can i portably test for
> presence and version of these libs on Linux, Windows and other OSes?

Not really.  There is distutils.ccompiler.find_library_file() and
friends which you might put to good use, but I've never seen it being
used or used it myself.  And it's quite complicated to get a usable
instance of CCompiler, expect to read distutils source.

But generally you can just use the platform default includes and then
it will simply fail to compile if they're not present.


Regards
Floris

-- 
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org


More information about the Distutils-SIG mailing list