You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will install two different keops modules:
<module 'pykeops' from '/usr/local/lib/python3.5/dist-packages/pykeops/init.py'>
<module 'pykeops' from '/usr/local/lib/python3.6/dist-packages/pykeops/init.py'>
Create python file test.py containing:
import pykeops
pykeops.clean_pykeops() # just in case old build files are still present
pykeops.test_numpy_bindings() # perform the compilation
The test script will fail for at least one python version:
python3.5 test.py fails with ImportError: dynamic module does not define module export function (PyInit_libKeOpsnumpyb10acd1892)
python3.6 test.py succeeds with pyKeOps with numpy bindings is working!
What really happens:
This happens because pykeops/common/compile_routines.py calls cmake on pykeops/CMakeLists.txt which contains add_subdirectory(pybind11) which will detect python3.6 by default (in this specific case). This generates a shared library <CACHE_DIR>/pykeops-1.3-cpython-35/libKeOpsnumpyb10acd1892.so targeting python 3.6 instead of 3.5 and the importlib module fails to load the library.
How to fix:
The simplest solution I found is to enforce the python version directly in the build script by using the PYBIND11_PYTHON_VERSION variable. Adding set(PYBIND11_PYTHON_VERSION 3.5) at the beginning of /usr/local/lib/python3.5/dist-packages/pykeops/CMakeLists.txt fixes the problem.
I imagine this could be done automatically by detecting python version during build / before installation. This fix could solve many issues such as #2#8#28#37 and others.
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
This will install two different keops modules:
<module 'pykeops' from '/usr/local/lib/python3.5/dist-packages/pykeops/init.py'>
<module 'pykeops' from '/usr/local/lib/python3.6/dist-packages/pykeops/init.py'>
python3.5 test.py
fails withImportError: dynamic module does not define module export function (PyInit_libKeOpsnumpyb10acd1892)
python3.6 test.py
succeeds withpyKeOps with numpy bindings is working!
What really happens:
This happens because
pykeops/common/compile_routines.py
calls cmake onpykeops/CMakeLists.txt
which containsadd_subdirectory(pybind11)
which will detect python3.6 by default (in this specific case). This generates a shared library<CACHE_DIR>/pykeops-1.3-cpython-35/libKeOpsnumpyb10acd1892.so
targeting python 3.6 instead of 3.5 and the importlib module fails to load the library.How to fix:
The simplest solution I found is to enforce the python version directly in the build script by using the PYBIND11_PYTHON_VERSION variable. Adding
set(PYBIND11_PYTHON_VERSION 3.5)
at the beginning of/usr/local/lib/python3.5/dist-packages/pykeops/CMakeLists.txt
fixes the problem.I imagine this could be done automatically by detecting python version during build / before installation. This fix could solve many issues such as #2 #8 #28 #37 and others.
The text was updated successfully, but these errors were encountered: