Reputation: 136379
When I create a wheel distribution with python setup.py bdist_wheel
of a package which contains cython code, then the platform tag fits to my current platform. Projects like numpy / scipy have a lot of different wheels online and I guess they use CI / CD platforms like Travis / Azure Piplelines for that. However, I wondered: Can I create wheel distributions of packages containing cython for other platforms than my own, using only my computer?
fib.pyx
def fib_iterative_cython(int n):
cdef long long a = 0
cdef long long b = 1
for i in range(n - 1):
a, b = b, a + b
return b
setup.py
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("fib.pyx")
)
Upvotes: 3
Views: 540
Reputation: 94502
Short answer: no.
Longer answer: you can distribute sdist (source distribution). This forces the users to compile the sources so they have to install developer tools. pip install
mostly handles compilation except Cython
: you need to teach your users to install Cython
first.
Detailed answer: no. Partially it's Python fault, but mostly not. There are problems at many levels. First, cross-compilers are problematic and cross-linkers even more so. Second, setuptools
doesn't know any cross-compiler.
Solution: the only way to build C-modules is to build them natively in virtual machines or Docker containers.
Upvotes: 2