473,795 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

portable extensions options for external libraries

Hi.

I want to create a portable setup.py file for windows / linux for an
extension package that i need to link with external libraries (gsl and
boost). on windows i do something like this:

imaging = Extension( 'pyag.imaging._ imaging',
sources = ( glob.glob(
'Source/pyag/imaging/Src/*.cpp' ) +
glob.glob(
'Source/pyag/imaging/Src/*.h' ) ),
include_dirs = ( get_numpy_inclu de_dirs() +
[ 'Source/pyag/imaging/Src/',
'C:/Program
Files/boost/include/boost-1_35',
'C:/Program
Files/GnuWin32/include'] ),
library_dirs = [ 'C:/Program Files/GnuWin32/lib'
],
libraries = [ 'libgsl', 'libgslcblas' ] )

obviously, the paths could vary. on unix, i need something like:

imaging = Extension( 'pyag.imaging._ imaging',
sources = ( glob.glob(
'Source/pyag/imaging/Src/*.cpp' ) +
glob.glob(
'Source/pyag/imaging/Src/*.h' ) ),
include_dirs = ( get_numpy_inclu de_dirs() +
[ 'Source/pyag/imaging/Src/' ] )
)

so my question is: what is the right way of specifying extensions
options (include_dirs, libraries, library_dirs) so that they are
portable between windows and linux? i'm thinking environment variables.
Though fairly easy to do, i was wondering if python/distutils provided
something more convenient, like searching through "common" directories,
though those aren't very standard on windows? Optimally, i would like
to have something like:

imaging = Extension( 'pyag.imaging._ imaging',
sources = ( glob.glob(
'Source/pyag/imaging/Src/*.cpp' ) +
glob.glob(
'Source/pyag/imaging/Src/*.h' ) ),
include_dirs = ( get_numpy_inclu de_dirs() +
[ 'Source/pyag/imaging/Src/' ] +
boost_include_d irs +
gsl_include_dir s ),
library_dirs = boost_library_d irs +
gsl_library_dir s,
libraries = boost_libraries + gsl_libraries )
thx for any help.

alex.

Oct 18 '06 #1
1 1379
Alexandre Guimond wrote:
so my question is: what is the right way of specifying extensions
options (include_dirs, libraries, library_dirs) so that they are
portable between windows and linux? i'm thinking environment variables.
The user can already use command-line options and CFLAGS if he so desires, so I
wouldn't add any new environment variables.

$ CFLAGS=-I/opt/local/include python setup.py build_ext -L/opt/local/lib
Though fairly easy to do, i was wondering if python/distutils provided
something more convenient, like searching through "common" directories,
though those aren't very standard on windows?
distutils wouldn't do any searching at all. Your compiler will, though.
Optimally, i would like
to have something like:

imaging = Extension( 'pyag.imaging._ imaging',
sources = ( glob.glob(
'Source/pyag/imaging/Src/*.cpp' ) +
glob.glob(
'Source/pyag/imaging/Src/*.h' ) ),
include_dirs = ( get_numpy_inclu de_dirs() +
[ 'Source/pyag/imaging/Src/' ] +
boost_include_d irs +
gsl_include_dir s ),
library_dirs = boost_library_d irs +
gsl_library_dir s,
libraries = boost_libraries + gsl_libraries )
That's pretty much how everyone else does it. Just make sure that
boost_{include, library}_dirs and gsl_{include,li brary}_dirs are defined near the
top of the file with suitable comments to draw attention to them.

However, I might suggest making a setup.cfg with something like the following
section (unindented):

# Uncomment and modify the following section to configure the locations of the
# Boost and GSL headers and libraries.

#[build_ext]
#include-dirs=/opt/local/include,/usr/local/include
#library-dirs=/opt/local/lib,/usr/local/lib

Changing data in a data file feels better to me than changing data in a program
for some reason.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 18 '06 #2

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

Similar topics

14
2629
by: John Smith | last post by:
Hi I'm looking for a header-file only STL implementation. I know the vendors provide one with compilers but often they are either buggy or has some other problems. My problem is that under Windows the different versions of the Microsoft compiler are not compatible with each other. This means you can't compile file with version X and link with version Y because you end up with linker errors.
385
17322
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every one are
9
4310
by: PengYu.UT | last post by:
Hi, I write the content of a in file "data" (in Sun Machine). Then I read "data" in both SunOS and linux. But the result is different. Do you know how to make it binary data portable. Best wishes, Peng
131
6230
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write portable C code - *not only* because, in a 'C sense', I
11
1995
by: Metaosp | last post by:
Hi, When it comes to code portability, most people would think C is a better choice then C++. That was probably true 5 or 10 years ago, but how about today? Are there still many platforms or devices that have no good C++ compiler? C++ offers a lot more then C, would you use it to build a new cross-platform project that will support a wide range of platforms, say from handheld devices to multi-nodes servers?
5
7629
by: Richard Giuly | last post by:
Hello, I would like to write "portable" C++ code that could theoretically run on linux, windows, and other platforms, and I'd like to use VS as the editor/compiler/linker. The simplest thing that seems to complie in VS is this: //VS example #include "stdafx.h"
42
3459
by: jacob navia | last post by:
http://slashdot.org/ "The leaner, lighter, faster, and most importantly, BSD Licensed, Compiler PCC has been imported into OpenBSD's CVS and NetBSD's pkgsrc. The compiler is based on the original Portable C Compiler by S. C. Johnson, written in the late 70's. Even though much of the compiler has been rewritten, some of the basics still remain. It is currently not bug-free, but it compiles on x86 platform, and work is being done on it to...
69
2654
by: Bill Reid | last post by:
This is how I handle a check that the last character of a text file is a newline: /* checks if newline is last character of text file */ unsigned check_text_file_newline_termination(FILE *test_file) { int end_char; fseek(test_file,-1L,SEEK_END); end_char=getc(test_file);
23
3352
by: asit | last post by:
what is the difference between portable C, posix C and windows C ???
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.