473,411 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Platform-specific compile flags in setup.py?

Hi all,
I'm a newbie when it comes to distributing C-based Python modules. I'm
just now sharing my first with the rest of the world (it's actually V.
Marangozov's shared memory module for IPC) and I've learned that the
module needs a different set of compile flags for Linux than for my Mac.
My question is this: is there a convention or standard that says where
platform-specific compile flags should reside? I could put them in
setup.py, OTOH I know that within the .C file I can add something like
this:
#ifdef __FreeBSD__
#include <machine/param.h /* for system definition of PAGE_SIZE */
#endif

That works, but for maximum Python programmer-friendliness I should
perhaps put the complexity in setup.py rather than in a .C file.

Opinions appreciated.

PS - The module in question is here; Linux users must remove the tuple
"('HAVE_UNION_SEMUN', None)" from setup.py:
http://NikitaTheSpider.com/python/shm/

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Mar 5 '07 #1
1 2049
Nikita the Spider <Ni*************@gmail.comwrote:
Hi all,
I'm a newbie when it comes to distributing C-based Python modules. I'm
just now sharing my first with the rest of the world (it's actually V.
Marangozov's shared memory module for IPC) and I've learned that the
module needs a different set of compile flags for Linux than for my Mac.
My question is this: is there a convention or standard that says where
platform-specific compile flags should reside? I could put them in
setup.py,
If you need, specifically, *compile-flags*, then setup.py is a good
place for them (also linker-flags &c).

OTOH I know that within the .C file I can add something like
this:
#ifdef __FreeBSD__
#include <machine/param.h /* for system definition of PAGE_SIZE */
#endif
This is NOT a "compile-flag" -- it's a reasonable C technique, though.

That works, but for maximum Python programmer-friendliness I should
perhaps put the complexity in setup.py rather than in a .C file.

Opinions appreciated.
My opinion: flags in setup.py, conditional includes (&c) in the .c or .h
file[s].

If you can do something either way: if you know platform X will ALWAYS
want that something, "hard-code" it in the .c or .h; if you want to make
it easier to change for Python programmers, then put it in the setup.py.
Alex
Mar 5 '07 #2

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

Similar topics

7
by: Web Master | last post by:
Are there any good websites or books that deal with cross platform XML? I'd like to target Internet Explorer/Netscape Navigator 5 or later, as well as Opera, possibly konqueror on Linux as well. ...
10
by: darkhack | last post by:
Hello. I am looking for a GUI API that is cross platform and works with Windows, Mac, and Linux. I was hoping for something free and open source. You see, I have yet to find anything that fits...
14
by: John Salerno | last post by:
Bear with me, but I've been reading a lot about how the .NET languages are platform independent, and I assume this means a program written in C# can be run on a Unix or Mac machine. If this...
8
by: Michiel Sikma | last post by:
Hello everybody, I was thinking about making a really insignificant addition to an online system that I'm making using Python: namely, I would like it to print the platform that it is running on...
16
by: Andy | last post by:
Hi, I have read that 'C' is platform-independent and portable. I can'tsee much a difference between the two terms. Could anyone differentiate the two? Also is the statement actually true? Thanks...
2
by: maha | last post by:
Dear DB2 experts! I'm stuck with the following issue: from a customer I got a DB2 backup file, created on an AIX-32 machine that I cannot restore on my windows platform. I admit that I posses...
0
by: marathoner | last post by:
I am currently migrating my Visual C++ 6.0 applications to Visual Studio 2005. I am getting compiler errors involving the VS2005's platform SDK. When I removed directory references to that SDK,...
28
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am developing C++ COM native code (unmanaged C++) using Visual Studio 2005. I do not take any new features of 64-bit platform, and currently my code runs fine on 32-bit...
1
by: Vinod Sadanandan | last post by:
Cross Platform Migration An Unproblematic Approach (Windows-UNIX ) Oracle 10\11g The principal restriction on cross-platform transportable database is that the source and destination platform...
2
xarzu
by: xarzu | last post by:
Platform Builder is a tool for building a Windows CE Operating system on your computer and then loading it on a Windows CE device. All this is done through Platform Builder. And I do it all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...

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.