building an extension module with autotools?

M

Michael George

Hello,

(Please CC me in replies, as I am off-list)

I'm building an application (a game) in python, with a single C module
containing some performance-critical code. I'm trying to figure out the
best way to set it up to build. Distutils seems to be designed only for
building and distributing code that lives in site-packages. I'd prefer
not to install it in the global site-packages, but rather group all of
the files together.

I've tried using automake, however I'm worried about libtool not getting
the options right while building my module. It seems to me like the
ideal frankenstein monster would be for automake to invoke distutils to
do the actual building. However I'm relatively new to both autotools
and distutils, so getting this rigged up has been a bit of a challenge.
Can anybody point me to a good example of something like this or give me
any pointers?

Thanks!

--Mike
 
G

Gerhard Häring

Michael said:
Hello,

(Please CC me in replies, as I am off-list)

Ok, but please reply publicly.
I'm building an application (a game) in python, with a single C module
containing some performance-critical code. I'm trying to figure out the
best way to set it up to build.

Use distutils and keep your sanity.
Distutils seems to be designed only for
building and distributing code that lives in site-packages. I'd prefer
not to install it in the global site-packages, but rather group all of
the files together.

Then just use the build step of distutils and do the rest from your
build script (Python-based, make based, whatever you prefer).
I've tried using automake,

In my opinion, this is serious overkill. automake is good for making
stuff work on a herd of different Unixen with various combinations of
libc functions available etc. But for developing a Python extension, it
doesn't help much at all. All you need to know about Python is available
via macros if you import Python.h.
however I'm worried about libtool not getting
the options right while building my module. It seems to me like the
ideal frankenstein monster would be for automake to invoke distutils to
do the actual building. However I'm relatively new to both autotools
and distutils, so getting this rigged up has been a bit of a challenge.
Can anybody point me to a good example of something like this or give me
any pointers?

My recommendation is to start simple instead of wasting too much time
upfront for probably nothing.

Here's what I'd start with:

#!/bin/sh
python setup.py build
cp build/lib.*/*.so .
python test.py

HTH

-- Gerhard
 
M

Martin v. Löwis

I've tried using automake, however I'm worried about libtool not getting
the options right while building my module.

You should use python-config(1) to obtain the command line options
necessary to build and link extension modules.

HTH,
Martin
 
M

Michael George

Gerhard said:
In my opinion, this is serious overkill. automake is good for making
stuff work on a herd of different Unixen with various combinations of
libc functions available etc. But for developing a Python extension,
it doesn't help much at all. All you need to know about Python is
available via macros if you import Python.h.
I'll definitely consider going the simpler route, although the other
thing that autotools provides is a standard interface for end-users.
For example I'm picky and don't let anything into /usr that isn't under
the purview of the package manager. autotools makes life easy because I
can just do ./configure --prefix=/opt/pkgname and I know I'm good.
Custom build setups force me to figure them out before I can install
(and sometimes even use) the program.

Since I'll be eventually trying to attract users, I'd like to avoid
scaring them away with custom build scripts :)
HTH

-- Gerhard

Thanks for the advice.

--Mike
 
M

Michael George

Martin said:
You should use python-config(1) to obtain the command line options
necessary to build and link extension modules.

HTH,
Martin

Sweet, I think that's exactly what I wanted. Thanks!

--Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top