[ccan] Using ccan with a C python extension

Stuart Longland stuartl at longlandclan.yi.org
Mon Jun 15 14:00:09 AEST 2015


On 15/06/15 12:01, Rusty Russell wrote:
> Naveen Nathan <naveen at lastninja.net> writes:
>> It is setup to be installed as a python package via pip/easy_install
>> which will:
>>     (1) fetch the python module
>>     (2) build the C extension, and finally
>>     (3) install it on the system (or virtual environment).
>>
>> I specifically want to use ccan/{bitmap,endian} but unsure how
>> to integrate the code into our project's build process.
>>
>> I envision at step (2) above, we will build libccan and statically
>> link it to the C extension. However, I will need a ccan config.h
>> which will vary per system. So this will involve generating the
>> file. Does that mean I should include the tools / configurator
>> as part of our python package?
> 
>         I think you should use autoconf, as it's the standard.  I keep
> hoping someone will write the autotools stuff for CCAN for me :)

Yeah, the trouble with that approach is that autoconf does a pretty poor
job of integrating into Python module builds.

The usual build system in Python is the `distutils` module, which
basically gets included into a Python script called 'setup.py' and called.

Then it's a *magic happens here* affair, where out the other end is your
Python module.

You'd have to hook something in that could call ./configure at the
appropriate time, and somehow convince the automated packaging tools
(stdeb, gsourcery-pypi, etc) to ignore ./configure and use setup.py.

I'm not sure what's needed in config.h; maybe there's some way to
generate this using some basic Python calls before building?
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.


More information about the ccan mailing list