balbasty / nitorch

Neuroimaging in PyTorch
Other
83 stars 14 forks source link

CI: compilation fails on python 3.7 (but not 3.6 or 3.8) #30

Open balbasty opened 3 years ago

balbasty commented 3 years ago

It's super weird: on github's CI server, the compilation fails [only] on python 3.7.

Failure happens at the last linking step (the extension files that binds the c++ code to python): the linker cannot find the python library libpython3.7m even though the python lib directory is correctly specified (/opt/hostedtoolcache/Python/3.7.9/x64/lib). Or maybe it isn't... (why is it not -L?)

g++ -pthread -shared \
    -Wl,--rpath=/opt/hostedtoolcache/Python/3.7.9/x64/lib \
    -Wl,--rpath=/opt/hostedtoolcache/Python/3.7.9/x64/lib \
    build/temp.linux-x86_64-3.7/_C/spatial/home/runner/work/nitorch/nitorch/nitorch/_C/spatial.o \
    -L/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/torch/lib \
    -Lbuild/lib.linux-x86_64-3.7/nitorch/lib \
    -Wl,--enable-new-dtags,-R$ORIGIN/../lib \
    -lc10 -ltorch_cpu -ltorch_python -ltorch -lnitorch -lpython3.7m \
    -o build/lib.linux-x86_64-3.7/nitorch/_C/spatial.cpython-37m-x86_64-linux-gnu.so

/usr/bin/ld: cannot find -lpython3.7m

Here's what happens on 3.6 (which does not fail):

g++ -pthread -shared \
    -Wl,--rpath=/opt/hostedtoolcache/Python/3.6.12/x64/lib \
    -Wl,--rpath=/opt/hostedtoolcache/Python/3.6.12/x64/lib \
    build/temp.linux-x86_64-3.6/_C/spatial/home/runner/work/nitorch/nitorch/nitorch/_C/spatial.o \
    -L/opt/hostedtoolcache/Python/3.6.12/x64/lib/python3.6/site-packages/torch/lib \
    -Lbuild/lib.linux-x86_64-3.6/nitorch/lib \
    -Wl,--enable-new-dtags,-R$ORIGIN/../lib \
    -lc10 -ltorch_cpu -ltorch_python -ltorch -lnitorch -lpython3.6m \
    -o build/lib.linux-x86_64-3.6/nitorch/_C/spatial.cpython-36m-x86_64-linux-gnu.so

I have disabled the tests on python 3.7 in the meantime