473,471 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

distutils: optionally build C bindings to an external library

Hi,

I've written a pure Python module, which could optionally use an
external C library. The external library is not required to be on the
user computer however, so I'd like not to build the bindings by default,
but allow a user to turn the build on by specifying some parameter to
`setup.py`. Basically, it should work like
./configure --with-some-lib[=/path]

Unfortunately I'm not quite sure how to implement this and I'm already
lost in the distutils internals. Could someone point me to the correct
direction, perhaps giving me a reference to an existing distutils
script?

--
xi
Oct 9 '06 #1
2 1610
Kirill Simonov schrieb:
I've written a pure Python module, which could optionally use an
external C library. The external library is not required to be on the
user computer however, so I'd like not to build the bindings by default,
but allow a user to turn the build on by specifying some parameter to
`setup.py`. Basically, it should work like
./configure --with-some-lib[=/path]

Unfortunately I'm not quite sure how to implement this and I'm already
lost in the distutils internals. Could someone point me to the correct
direction, perhaps giving me a reference to an existing distutils
script?
You can add any parameters to setup.py yourself; just look for the
parameter, and then remove it from argv before invoking distutils.
It would be even better if the user wouldn't have to specify the
location, but instead setup.py looked at a few candidate places
itself.

If you really want to use the distutils command line option processing
machinery, you should inherit from the build command, extend
user_options (by putting a new user_options into the subclass, rather
than appending to the user_options of the base class), and overwrite
initialize_options and finalize_options (calling the base class).
If "build" is too broad, "build_ext" might be the better place.

Regards,
Martin
Oct 9 '06 #2
Kirill Simonov schrieb:
I've written a pure Python module, which could optionally use an
external C library. The external library is not required to be on the
user computer however, so I'd like not to build the bindings by default,
but allow a user to turn the build on by specifying some parameter to
`setup.py`. Basically, it should work like
./configure --with-some-lib[=/path]

Unfortunately I'm not quite sure how to implement this and I'm already
lost in the distutils internals. Could someone point me to the correct
direction, perhaps giving me a reference to an existing distutils
script?
You can add any parameters to setup.py yourself; just look for the
parameter, and then remove it from argv before invoking distutils.
It would be even better if the user wouldn't have to specify the
location, but instead setup.py looked at a few candidate places
itself.

If you really want to use the distutils command line option processing
machinery, you should inherit from the build command, extend
user_options (by putting a new user_options into the subclass, rather
than appending to the user_options of the base class), and overwrite
initialize_options and finalize_options (calling the base class).
If "build" is too broad, "build_ext" might be the better place.

Regards,
Martin
Oct 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Isaac Jones | last post by:
Hello Python Community. I bring greetings from the Haskell community (http://www.haskell.org) ;) There has been a lot of discussion of late about creating a grand-unified build & distribution...
1
by: Mathieu Malaterre | last post by:
Hello, I thought this would be easy but I guess I didn't get the distutil feeling. I am trying to write a setup for install my package but I don't understand how to do that. organisation: ...
0
by: Christopher De Vries | last post by:
The predominant operating system in my workplace is Solaris, with a bit of Linux and MacOS X thrown in. As such people expect to install new software with the sequence: ../configure make make...
0
by: Maarten Sneep | last post by:
I'm trying to build PyBison on Mac OS X, and I'm running into some problems with the distutils. Just for starters: PyBison requires Pyrex. This is not a problem, and Pyrex seems to work without...
0
by: Glenn Pierce | last post by:
Hi I have a question about writing a portable setup.py script for distutils. I have a directory structure like this. FreeImage/ |----------Source/ | |------ FreeImage.h |...
3
by: mg | last post by:
Hello I work on an finite element framework and Python bindings have been developped. Actually, we use Boost.Build as build system but we would like to change it. We have two kinds of...
6
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self,...
9
by: jtravs | last post by:
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment...
7
by: Steven Bethard | last post by:
How do I get distutils to include my testing module in just the "sdist" distribution? My current call to setup() looks like:: distutils.core.setup( ... py_modules=, ) If change this to::
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.