473,796 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_S EMUN', 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 2064
Nikita the Spider <Ni************ *@gmail.comwrot e:
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
4844
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. OT: I'm also looking for books and websites for cross platform XHTML and DHTML.
10
2422
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 this criteria. GTK+ is good, but it doesn't work on the Mac. Qt claims to work on all Operating Systems, but it requires a recompile on that platform and I've yet to figure out how to accomplish that without buying the commerical version. So...
14
2147
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 assumption is wrong, then nevermind! :) But if it's true, what will be necessary to run these programs on a Mac, for example? I know they would need an equivalent to the .NET Framework, but does something like this exist yet, or is the "platform...
8
3526
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 in a human-readable manner. I was thinking of doing it like this: import sys platforms = {
16
3930
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 Andy
2
5584
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 only limited knowledge on the administration side of DB2, but I have done a lot of research, without solving the problem. What I tried: For a regular RESTORE I would need a linux Big Endian machine
0
6689
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, and started using the Microsoft Platform SDK for XP SP2, the errors disappeared, but I am now getting numerous warnings (macro redefinitions) as follows: StdAfx.cpp WINVER not defined. Defaulting to 0x0502 (Windows Server 2003) C:\Program...
28
2751
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 platform (e.g. Windows XP SP2). Now I am researching how to build my code for 64-bit platform (e.g. Windows 2003 Server 64-bit R2)? Any options I need to specify in Visual Studio 2005? The best solution to me is to make a single build for both 32-bit...
1
7828
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 must share the same endian format. Redo log files and control files from the source database are not transported to destination database . New control files and redo log files are created for the new database during the transport process, and an ...
2
1964
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 through the Microsoft Visual Stuido Development Environment (IDE). I want to automate the process of using the Platform Builder. So far, I only know how to use the Platform Builder through the IDE. I want to use the Platform Builder through another...
0
9528
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
10228
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...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
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
9052
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
6788
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.