Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set C/C++ compiler for Python extensions

Tags:

c++

python

linux

I would like to setup a default C and C++ compiler when building Python extensions under Linux. I noticed the --compiler option to python setup.py build, but I am wondering if there is a way of setting this as an environmental variable so that I can specify them just once.

like image 771
Andrea Zonca Avatar asked Feb 26 '11 00:02

Andrea Zonca


People also ask

What C compiler does Python use?

Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compiler as it compiles Python code into bytecode before interpreting it.

Does Python compile to C?

Compile Python to CPython code can make calls directly into C modules. Those C modules can be either generic C libraries or libraries built specifically to work with Python. Cython generates the second kind of module: C libraries that talk to Python's internals, and that can be bundled with existing Python code.

What C compiler does Cython use?

MSVC is the only compiler that Cython is currently tested with on Windows. A possible alternative is the open source MinGW (a Windows distribution of gcc).


1 Answers

It's not possible to use an environment variable, but you can create a setup.cfg file. See Writing the Setup Configuration File. The following setup.cfg file will try to use the Intel C Compiler:

[build_ext] 
compiler=icc
like image 67
casevh Avatar answered Oct 12 '22 03:10

casevh