Для сборки я использую distutils:
python setup.py build_ext --inplace
Создание простого pyx
-файла работает (setup.py):
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize('test.pyx')
)
Создание нескольких файлов (setup.py):
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
# This is the new part...
extensions = [
Extension('test', ['test.pyx', 'test2.pyx'])
]
setup(
ext_modules = cythonize(extensions)
)
test2.pyx:
def say_hello_to2(name):
print("Hello %s!" % name)
Сборка выше работает нормально, и я вижу, что и компиляция, и компоновка завершены успешно, но не похоже, что метод say_hello_to2
находится в двоичном файле. Запуск python, запуск ниже показывает, что в модуле есть только методы test.pyx
is:
>>> import test
>>> dir(test)
['InheritedClass', 'TestClass', '__builtins__', '__doc__', '__file__', '__name__
', '__package__', '__test__', 'fib', 'fib_no_type', 'primes', 'say_hello_to', 's
in']
>>>
Можно ли добавить более одного pyx
файла в сборку расширения?