У меня есть очень маленькая программа m2_mod.pyx, которую я хотел бы преобразовать в файл .so для включения. в основной программе Python:
Код: Выделить всё
from libc.math cimport pow
cdef float hypotenuse(float x, y):
return pow(x*x + y*y, 0.5)
cpdef print_hypotenuse(float x, y):
print("%4.3f, %4.3f, %4.3f" % (x, y, hypotenuse(x, y)) )
Код: Выделить всё
from setuptools import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize(["m2_mod.pyx"]))
Код: Выделить всё
Compiling m1_mod.pyx because it changed.
[1/1] Cythonizing m1_mod.pyx
/usr/local/lib/python3.10/dist-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /mnt/c/USR/Programming/Python/WI - Lic/wsl/use_cython/m1_mod.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'm1_mod' extension
creating build
creating build/temp.linux-x86_64-3.10
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.10 -c m1_mod.c -o build/temp.linux-x86_64-3.10/m1_mod.o
creating build/lib.linux-x86_64-3.10
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.10/m1_mod.o -o build/lib.linux-x86_64-3.10/m1_mod.cpython-310-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.10/m1_mod.cpython-310-x86_64-linux-gnu.so ->
error: [Errno 1] Operation not permitted
Подробнее здесь: https://stackoverflow.com/questions/792 ... but-the-so