It seems that this issue is occured when link is executed via dh.
dh_auto_build --sourcedirectory=python --buildsystem=pybuild
invokes the following command:
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
-Wl,-z,relro -g -fwrapv -O2 -Wl,-z,relro -g -O2
-ffile-prefix-map=/debian/sentencepiece.tmp=. -fstack-protector-strong -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
build/temp.linux-x86_64-3.9/src/sentencepiece/sentencepiece_wrap.o -o
/debian/sentencepiece.tmp/.pybuild/cpython3_3.9/build/sentencepiece/_sentencepiece.cpython-39-x86_64-linux-gnu.so
-L/debian/sentencepiece.tmp/obj-x86_64-linux-gnu/src -lsentencepiece
-lsentencepiece_train
When the above command is executed via dh_auto_build, there is no refererence to
libsentencepiece.
ldd
/debian/sentencepiece.tmp/.pybuild/cpython3_3.9/build/sentencepiece/_sentencepiece.cpython-39-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffd3edbb000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f8217f81000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8217f67000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8217da2000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8217c5e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8218170000)
Instead, link is executed via console by hand, the reference to
libsentencepiece exists.
ldd
/debian/sentencepiece.tmp/.pybuild/cpython3_3.9/build/sentencepiece/_sentencepiece.cpython-39-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffd3edbb000)
libsentencepiece.so.0 => not found
libsentencepiece_train.so.0 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f8217f81000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8217f67000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8217da2000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8217c5e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8218170000)
When .so is built via console, it is loaded from python expectedly (it should
be installed manually)
$ python3 -c "import sentencepiece; print(sentencepiece)"
<module 'sentencepiece' from
'/usr/lib/python3/dist-packages/sentencepiece/__init__.py'>