By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.