Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I merge multiple Cython pyx files into a single linked library? [duplicate]

Tags:

python

cython

I have multiple .pyx files, is there a way to import them into a single pyx file and compile that file into a shared library, instead of having to compile 15 independent modules?

like image 932
HaltingState Avatar asked Jan 07 '12 20:01

HaltingState


People also ask

Does Cython generate C code?

The Cython compiler will convert it into C code which makes equivalent calls to the Python/C API. But Cython is much more than that, because parameters and variables can be declared to have C data types.

What are PYX files?

What is a PYX file? A PYX file is a source code written in the Python-like language Pyrex. It may contain code that references existing C modules. Pyrex is a programming language that is used for creating Python modules PYD and is based on C-like syntax.

What C compiler does Cython use?

Linux The GNU C Compiler (gcc) is usually present, or easily available through the package system. On Ubuntu or Debian, for instance, it is part of the build-essential package. Next to a C compiler, Cython requires the Python header files.


1 Answers

At the moment, it seems the only way is to create a master .pyx file that uses include directives to create a monolithic .C file.

See project structure for wrapping many c++ classes in cython to a single shared object.

like image 162
Mr Fooz Avatar answered Oct 20 '22 05:10

Mr Fooz