Closed abeschneider closed 7 years ago
Any solution for this? My script is working but the package doesn't (with the same above SystemError). I copied the binary from the compiled script to overwrite binary in the compiled package and it works. How are they (the binaries) different?
After some investingation, I think I've pinpointed the problem. It only affects python 2, not python 3 (from tests with anaconda 2.7 and 3.6).
With Python 2, cfft
expects the package to be loaded from the directory of build.py
. Therefore, if you build the package, and change directories into my_package
and run
import _ext.my_lib
then there will be no error. However, running
import my_package._ext.mylib
from the package root directory (or any other directory after installation) will cause the SystemError
.
One workaround that I have found is
1) moving the build.py
script to the root directory
2) Adding the my_package/
prefix to the headers and source files in build.py
3) Setting ext_package
to ''
in setup.py
.
4) Removing the prefix my_package
from lines in setup.py
.
This fix makes packages work in Python 2.7, and they still work in Python 3.
I'm not sure if this is a change that should be made to this example code, or if this is a temporary workaround until we can get a bug fixed in cfft
. Maintainers, any thoughts?
@gpleiss Can you please submit a PR? Thank you!
Sure thing!
I installed
my_package
and rantest.py
underextension-ffi/package/test
and got the error:This was run on Mac OS 10.12.3 using Python 2.7 with the most up to date version of PyTorch from
master
.Trying investigate, I tried to import
my_package.modules
, I don't get an error, but if I try to importmy_package.modules.add
I get: