473,287 Members | 1,827 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,287 software developers and data experts.

Extending Python with C: Can I specify another C compiler?

Hello.

I am trying to extend my Python program with some C code.

This thread is sort of a follow-up to another thread of mine, linked
below. I don't know what the conventions are in this newsgroup about
creating new threads vs. staying in existing ones, but I figured I'd
rather make a new one with a title pertaining to my current problem.

http://groups.google.com/group/comp....449f4db19f731#

Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function
distutils.core.setup... can I choose which C compiler to use? On my
system it defaults to gcc, but I would like to use mpicc instead (C
compiler for MPI, Message Passing Interface).

Can I do this?

My system, in case it matters, is Fedora Linux.

Thanks in advance.
Jun 27 '08 #1
5 1494
sp********@gmail.com wrote:
Hello.

I am trying to extend my Python program with some C code. [...]
Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function
distutils.core.setup... can I choose which C compiler to use? On my
system it defaults to gcc, but I would like to use mpicc instead (C
compiler for MPI, Message Passing Interface). [...]
Try:

$ export CC=mpicc
$ python setup.py build

HTH,

-- Gerhard

Jun 27 '08 #2
On Jun 4, 6:25*pm, Gerhard Häring <g...@ghaering.dewrote:
spectru...@gmail.com wrote:
* Hello.
* I am trying to extend my Python program with some C code. [...]
* Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function
distutils.core.setup... can I choose which C compiler to use? On my
system it defaults to gcc, but I would like to use mpicc instead (C
compiler for MPI, Message Passing Interface). [...]

Try:

$ export CC=mpicc
$ python setup.py build

HTH,

-- Gerhard
Yes, that worked. Thank you. :)
Jun 27 '08 #3
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote:
Hello.

I am trying to extend my Python program with some C code.

This thread is sort of a follow-up to another thread of mine, linked
below. I don't know what the conventions are in this newsgroup about
creating new threads vs. staying in existing ones, but I figured I'd
rather make a new one with a title pertaining to my current problem.

http://groups.google.com/group/comp....thread/thread/
d60449f4db19f731#
>
Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function distutils.core.setup...
can I choose which C compiler to use? On my system it defaults to gcc,
but I would like to use mpicc instead (C compiler for MPI, Message
Passing Interface).

Can I do this?

My system, in case it matters, is Fedora Linux.

Thanks in advance.
There is -c option for setup.py build and setup.py build_ext. If it
doesn't work for your compiler you probably have to build your extensions
manually.

Ivan
Jun 27 '08 #4
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote:
Hello.

I am trying to extend my Python program with some C code.

This thread is sort of a follow-up to another thread of mine, linked
below. I don't know what the conventions are in this newsgroup about
creating new threads vs. staying in existing ones, but I figured I'd
rather make a new one with a title pertaining to my current problem.

http://groups.google.com/group/comp....thread/thread/
d60449f4db19f731#
>
Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function distutils.core.setup...
can I choose which C compiler to use? On my system it defaults to gcc,
but I would like to use mpicc instead (C compiler for MPI, Message
Passing Interface).

Can I do this?

My system, in case it matters, is Fedora Linux.

Thanks in advance.
There is -c option for setup.py build and setup.py build_ext. If it
doesn't work for your compiler you probably have to build your extensions
manually.

Ivan
Jun 27 '08 #5
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote:
Hello.

I am trying to extend my Python program with some C code.

This thread is sort of a follow-up to another thread of mine, linked
below. I don't know what the conventions are in this newsgroup about
creating new threads vs. staying in existing ones, but I figured I'd
rather make a new one with a title pertaining to my current problem.

http://groups.google.com/group/comp....thread/thread/
d60449f4db19f731#
>
Anyway, my question is this: When compiling my C code to include in
Python, using a Python script with the function distutils.core.setup...
can I choose which C compiler to use? On my system it defaults to gcc,
but I would like to use mpicc instead (C compiler for MPI, Message
Passing Interface).

Can I do this?

My system, in case it matters, is Fedora Linux.

Thanks in advance.
There is -c option for setup.py build and setup.py build_ext. If it
doesn't work for your compiler you probably have to build your extensions
manually.

Ivan
Jun 27 '08 #6

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

Similar topics

24
by: Jean-Baptiste PERIN | last post by:
Hi, I'm trying to make a windows dll reachable from a python script .. and I'm encountering troubles during link step .. I use "lcc" to compile and link I use python 2.3 under win XP ...
1
by: Tommy Nordgren | last post by:
I want to write an application that embeds and extends (at least) the Python and Perl interpreters. Now i want to find as much as possible about the Python tools used for extending and embedding...
6
by: jeremito | last post by:
I am learning how to extend Pythong with C++. I have will be writing some code in C++ and want/need Python to interact with it. I am not having success following the online documentation from...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
7
by: Maximus Decimus | last post by:
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced...
7
by: Spectrum | last post by:
I am writing some Python code using the Message Passing Interface (MPI), an API used in parallel computing. There exist a number of Python implementations of MPI, but apparently they all rely on...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.