Steven Lutz
Steven Lutz

Reputation: 477

Does Cython compile imported modules as part of the binary?

I'm just now reading into cython and I'm wondering if cython compiles imported modules as part of the executable of if you still need to have the modules installed on the target machine to run the cython binary.

Upvotes: 3

Views: 906

Answers (1)

Pierre de Buyl
Pierre de Buyl

Reputation: 7293

The "interface" of a Cython module remains at the Python level. When you import a module in Cython, the module becomes available only at the Python level of the code and uses the regular Python import mechanism.

So:

  1. Cython does not "compile in" the dependencies.
  2. You need to install the dependencies on the target machine.

For "Cython level" code, including the question of "cimporting" module, Cython uses the equivalent of C headers (the .pxd declaration files) and dynamically loaded libraries to access external code. The .so files (for Linux, DLL for windows and dylib for mac) need to be present on the target machine.

Upvotes: 2

Related Questions