Help with package a library with python bindings

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with package a library with python bindings

Christophe Trophime
Hi,
I'm trying to package a library freesteam.
I'm moving their build system from scons to cmake to be able to build python bindings
for both python and python3.

I've managed to get cmake working
but I have trouble with swig generated python bindings.
More precisely:

dpkg-shlibdeps: warning: debian/python-freesteam/usr/lib/python2.7/dist-packages/_freesteam.x86_64-linux-gnu.so contains an unresolvable reference to symbol _Z19freesteam_region_pudd: it's probably a plugin

the missing symbols are actually in the libfreesteam.so  library build at the same time.
What shall I do to get _freesteal..so to get the symbols from plain libfreesteam.so?

Best
C

PS:
The CMakeLists.txt for the python bindings looks like this:

cmake_policy(SET CMP0078 OLD)

find_package(SWIG )
if (SWIG_FOUND)
  INCLUDE(${SWIG_USE_FILE})
  
  include_directories(${PYTHON_INCLUDE_DIRS})
  
  set(PYFREESTEAM_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages/)

  set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY)
  set_property(SOURCE freesteam.i PROPERTY CPLUSPLUS ON)

  swig_add_library(freesteam TYPE SHARED LANGUAGE python SOURCES freesteam.i)

  swig_link_libraries(freesteam ${PYTHON_LIBRARIES} freesteam)
  install(TARGETS ${SWIG_MODULE_freesteam_REAL_NAME} DESTINATION ${PYFREESTEAM_INSTALL_DIR})
  install(FILES ${CMAKE_BINARY_DIR}/python/freesteam.py DESTINATION ${PYFREESTEAM_INSTALL_DIR})

endif()

and the debian/rules:

override_dh_auto_configure:
dh_auto_configure -Bbuild.python3 -- $(extra_flags) -DFREESTEAM_PYTHON_VERSION=3
dh_auto_configure -Bbuild.python2 -- $(extra_flags) -DFREESTEAM_PYTHON_VERSION=2.7

override_dh_auto_build:
dh_auto_build -Bbuild.python3
dh_auto_build -Bbuild.python2

override_dh_auto_install:
dh_auto_install -Bbuild.python3
dh_auto_install -Bbuild.python2
ldd debian/tmp/usr/lib/python*/dist-packages/_freesteam*.so

override_dh_auto_test:
dh_auto_test -Bbuild.python3
cd build.python3 && ./test
dh_auto_test -Bbuild.python2
cd build.python2 && ./test

override_dh_shlibdeps:
dh_makeshlibs
dh_shlibdeps -v

and d/control:

Source: freesteam
Section: contrib/science
Priority: extra
Maintainer: John Pye <[hidden email]>
Build-Depends: debhelper (>= 9), cmake, gcc (>= 4.3), swig, 
 libgsl-dev (>= 2.3+dfsg-1~),
 dh-python,
 python3-all-dev (>= 3.5~), 
 python-all-dev (>= 2.6.6-3~)
X-Python-Version: current
X-Python3-Version: >= 3.2
Standards-Version: 3.7.2
...
Package: python-freesteam
Architecture: any
Section: python
Depends: libfreesteam-dev (= ${binary:Version}), ${python:Depends}
Description:Steam properties calculation library (Python bindings)
...

Christophe TROPHIME
Research Engineer

    CNRS - LNCMI
25, rue des Martyrs
BP 166
38042 GRENOBLE Cedex 9
FRANCE    

Tel : +33 (0)4 76 88 90 02
Fax : +33 (0) 4 76 88 10 01
Office U 19
M@il : [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with package a library with python bindings

Mo Zhou
Hi Christophe,

On Wed, Apr 17, 2019 at 01:35:13PM +0200, Christophe Trophime wrote:
> I'm moving their build system from scons to cmake to be able to build python
> bindings for both python and python3.

Please don't create more python2 packages, as per the python policy.
 

> I've managed to get cmake working
> but I have trouble with swig generated python bindings.
> More precisely:
>
> dpkg-shlibdeps: warning: debian/python-freesteam/usr/lib/python2.7/
> dist-packages/_freesteam.x86_64-linux-gnu.so contains an unresolvable reference
> to symbol _Z19freesteam_region_pudd: it's probably a plugin
>
> the missing symbols are actually in the libfreesteam.so  library build at the
> same time.
> What shall I do to get _freesteal..so to get the symbols from plain
> libfreesteam.so?

~ ❯❯❯ echo _Z19freesteam_region_pudd | c++filt
freesteam_region_pu(double, double)

That means the function "freesteam_region_pu(double, double)" is called
through FFI, or the dynamic linker (dlsym). Please take a look in the
code, and you can ignore this warning if it's true.

Reply | Threaded
Open this post in threaded view
|

Re: Help with package a library with python bindings

Christophe Trophime


----- Original Message -----
> From: "Mo Zhou" <[hidden email]>
> To: "Christophe Trophime" <[hidden email]>
> Cc: "debian-science" <[hidden email]>
> Sent: Wednesday, April 17, 2019 3:12:26 PM
> Subject: Re: Help with package a library with python bindings

> Hi Christophe,
>
> On Wed, Apr 17, 2019 at 01:35:13PM +0200, Christophe Trophime wrote:
>> I'm moving their build system from scons to cmake to be able to build python
>> bindings for both python and python3.
>
> Please don't create more python2 packages, as per the python policy.
>
>> I've managed to get cmake working
>> but I have trouble with swig generated python bindings.
>> More precisely:
>>
>> dpkg-shlibdeps: warning: debian/python-freesteam/usr/lib/python2.7/
>> dist-packages/_freesteam.x86_64-linux-gnu.so contains an unresolvable reference
>> to symbol _Z19freesteam_region_pudd: it's probably a plugin
>>
>> the missing symbols are actually in the libfreesteam.so  library build at the
>> same time.
>> What shall I do to get _freesteal..so to get the symbols from plain
>> libfreesteam.so?
>
> ~ ❯❯❯ echo _Z19freesteam_region_pudd | c++filt
> freesteam_region_pu(double, double)
>
> That means the function "freesteam_region_pu(double, double)" is called
> through FFI, or the dynamic linker (dlsym). Please take a look in the
> code, and you can ignore this warning if it's true.

Unfortunatly I cannot ignore this warning.

As far as I've understood, ldd _freesteam.x86_64-linux-gnu.so
should somehow contain libfreesteam.so to fix this pb...

right?

Reply | Threaded
Open this post in threaded view
|

Re: Help with package a library with python bindings

Felix Salfelder
On Wed, Apr 17, 2019 at 03:33:36PM +0200, Christophe Trophime wrote:
> Unfortunatly I cannot ignore this warning.

why? does the program not work?

> As far as I've understood, ldd _freesteam.x86_64-linux-gnu.so
> should somehow contain libfreesteam.so to fix this pb...
>
> right?

on POSIX systems, plugins resolve symbols in the namespace of the calling
process. possibly the program makes use of this feature. then, in your
case, dpkg-shlibdeps does not seem to know that your shared object file
is actually a plugin. assuming that your program is running, the warning
is the only issue, and it is a false positive.

see dpkg-shlibdeps(1), DIAGNOSTICS section

"""
  binary contains an unresolvable reference to symbol sym: it's probably a plugin
         The indicated symbol has not been found in the libraries linked with the  binary.  The
         binary is most likely a plugin and the symbol is probably provided by the program that
         loads this plugin. In theory a plugin doesn't have any SONAME  but  this  binary  does
         have one [..]
"""

you can avoid the warning by removing the SONAME in the plugin.

hth
felix