1

I have some python files, and all operation exposure to others in a Main file. I want to compile them and distribute one .so for others.

I try cython to compile them but more than one .so generated (works but not perfect).

example:

The folder structure is:

CythonExample/
|——for_call.py
|——setup.py
|——Student.py

setup.py

from distutils.core import setup, Extension
from Cython.Build import cythonize

setup(
    ext_modules=cythonize(["Student.py", "for_call.py"]),
)

python setup.py build_ext --inplace then I get Student.so and for_call.so.

I modify setup.py to:

from distutils.core import setup, Extension
from Cython.Build import cythonize

setup(
    name='sayname',
    ext_modules=cythonize(Extension("sayname", sources=["Student.py", "for_call.py"], language="c")),
)

then python setup.py build_ext --inplace, well, only sayname.so generated. but when i try to import it.

import sayname

ImportError: dynamic module does not define init function (initsayname)

thanks.

AlexV
  • 578
  • 8
  • 19
Eric Tu
  • 21
  • 5
  • [This question](https://stackoverflow.com/questions/30157363/collapse-multiple-submodules-to-one-cython-extension?noredirect=1&lq=1) might also be useful, but describes a slightly different folder structure. But the general upshot is this isn't _really_ supported in Cython but it's sometimes possible to do it in a hacky way – DavidW Mar 11 '19 at 14:13

0 Answers0