[Python] cython setuptools change output filename

Discussão em 'Python' iniciado por Stack, Março 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am using cython to cross-compile external python module. I am using python3.6 on the host and python3.5 on the target. Also I am compiling on x86_64 for target aarch64.

    My setup.py looks like:

    from distutils.core import setup
    from distutils.extension import Extension
    from Cython.Build import cythonize
    from Cython.Distutils import build_ext
    import builder_config
    import os

    os.environ["PATH"] = builder_config.PATH
    os.environ["CC"] = builder_config.COMPILER
    os.environ["LDSHARED"] = builder_config.COMPILER + " -lpython3.5m -shared"
    os.environ["CFLAGS"] = builder_config.CFLAGS
    os.environ["LDFLAGS"] = builder_config.LDFLAGS
    os.environ["ARCH"] = "aarch64"

    setup(
    ext_modules = cythonize((Extension("my_ext", ["file1.pyx", "file2.pyx", "file3.pyx", "file4.pyx", "file5.pyx"]))),
    )


    When I run python3.6 setup.py build_ext -i I get a file named: my_ext.cpython-36m-x86_64-linux-gnu.so

    My problem is that on the target the library will not be loaded unless the name is changed to:

    my_ext.cpython-35m-aarch64-linux-gnu.so

    How can I change the generated filename?

    Continue reading...

Compartilhe esta Página