I have a very basic test script for cython
test1.pyx:
def do_something(f):
return f
def main():
f = 1
print do_something(f)
if __name__ == "__main__":
main()
Which I compile with:
cython test1.pyx
gcc -Wall -O2 -g -lm -shared -pthread -fPIC -fwrapv -fno-strict-aliasing -Iinclude/python2.6 -o test1.so test1.c
And it works:
./bin/python -c "import test1; test1.main()"
1
But calling it directly as a module doesn’t work:
./bin/python -m test1
/mypath/bin/python: No code object available for test1
Why does this not work? How can I get it to work to directly call a cython script?
Cython version 0.12.1
Use the
--embedoption. Here is an example