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
I'm trying to do a multi Python namespace package build for our project, where each namespace package has a shared C++ library and one or more Python modules bound using pybind11. It works when all the packages are built on the same platform (tested with macos, ubuntu, and with cibuildwheel using manylinux2014) but fails with "TypeError: incompatible function arguments" if the first package is built into a wheel with cibuildwheel using manylinux2014 and the second package is built on ubuntu for CI testing. When, for example, the second package is also built with cibuildwheel using manylinux2014, the tests all pass.
From issues, it seems like it's a symbol visibility issue? But I can't seem to figure out what needs to be done to fix it. Here is the package layout:
mypackage-a:
include/ # C++ only
mypackage/a/classA.hh
python/
mypackage/ # python only
a/
__init__.py
src/ # pybind11 bindings
_a.cpp
src/ # C++ only
mypackage/a/classA.cc
mypackage-b:
include/ # C++ only
b/
subpackage1/classB1.hh
subpackage2/classB1.hh
python/
mypackage/ # python only
b/
__init__.py
subpackage1/
__init__.py
subpackage2/
__init__.py
src/ # pybind11 bindings
_b_subpackage1.cpp
_b_subpackage2.cpp
src/ # C++ only
b/
subpackage1/classB1.cc
subpackage2/classB2.cc
mypackage::a::ClassA is declared in mypackage/a/classA.hh and implemented in libmypackage_a.so
pybind11 is used to bind mypackage::a::ClassA to mypackage.a._a.ClassA
In mypackage/a/__init__.py we do: from ._a import ClassA
In mypackage/a/_a.cpython-310-x86_64-linux-gnu.so we set rpath "$ORIGIN/../lib"
mypackage-a is built into a wheel using cibuildwheel with manylinux2014, but without auditwheel.
In mypackage-b:
In mypackage_b.so we set rpath "$ORIGIN"
In mypackage/b/subpackage1/_b_subpackage1.cpython-310-x86_64-linux-gnu.so we set rpath "$ORIGIN/../../lib"
In python/src/_b_subpackage1.cpp of mypackage-b we bind using pybind11:
includes apy::module_::import("mypackage.a"); statement
binds some_function in that has mypackage::a::ClassA as arguments so that mypackage.a._a has a function some_function that takes mypackage.a.ClassA as arguments
In mypackage/b/subpackage1/__init__.py we do: from ._b_subpackage1 import some_function
mypackage-a is installed using the wheel, and mypackage-b is built on ubuntu:latest with github actions and installed.
Then a Python test is run in which mypackage.a.ClassA objects are used as arguments to mypackage.b.subpackage1.some_function.
The tests fail with the following type of errors:
TypeError: some_function(): incompatible function arguments. The following argument types are supported:
1. (arg0: mypackage::a::ClassA, arg1: mypackage::a::ClassA) -> int
Invoked with: <mypackage.a._a.classA object at 0x7ff2f052fd70>, <mypackage.a._a.classA object at 0x7ff2f0826c70>
C++ tests in mypackage-b all pass using the shared library from mypackage-a.
Again, everything passes if both packages are built using the same platform, for all the platforms I'ved tried (macos, ubuntu, cibuildwheel with manylinux2014, centos).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to do a multi Python namespace package build for our project, where each namespace package has a shared C++ library and one or more Python modules bound using pybind11. It works when all the packages are built on the same platform (tested with macos, ubuntu, and with cibuildwheel using manylinux2014) but fails with "TypeError: incompatible function arguments" if the first package is built into a wheel with cibuildwheel using manylinux2014 and the second package is built on ubuntu for CI testing. When, for example, the second package is also built with cibuildwheel using manylinux2014, the tests all pass.
From issues, it seems like it's a symbol visibility issue? But I can't seem to figure out what needs to be done to fix it. Here is the package layout:
mypackage-a:
mypackage-b:
install in site-packages:
Everything is built with scikit-build / CMake.
Example issue:
In mypackage-a:
mypackage::a::ClassA
is declared inmypackage/a/classA.hh
and implemented inlibmypackage_a.so
mypackage::a::ClassA
tomypackage.a._a.ClassA
mypackage/a/__init__.py
we do:from ._a import ClassA
mypackage/a/_a.cpython-310-x86_64-linux-gnu.so
we set rpath "$ORIGIN/../lib"mypackage-a is built into a wheel using cibuildwheel with manylinux2014, but without auditwheel.
In mypackage-b:
mypackage_b.so
we set rpath "$ORIGIN"mypackage/b/subpackage1/_b_subpackage1.cpython-310-x86_64-linux-gnu.so
we set rpath "$ORIGIN/../../lib"python/src/_b_subpackage1.cpp
of mypackage-b we bind using pybind11:py::module_::import("mypackage.a");
statementsome_function
in that hasmypackage::a::ClassA
as arguments so thatmypackage.a._a
has a functionsome_function
that takesmypackage.a.ClassA
as argumentsmypackage/b/subpackage1/__init__.py
we do:from ._b_subpackage1 import some_function
mypackage-a is installed using the wheel, and mypackage-b is built on ubuntu:latest with github actions and installed.
Then a Python test is run in which
mypackage.a.ClassA
objects are used as arguments tomypackage.b.subpackage1.some_function
.The tests fail with the following type of errors:
C++ tests in mypackage-b all pass using the shared library from mypackage-a.
Again, everything passes if both packages are built using the same platform, for all the platforms I'ved tried (macos, ubuntu, cibuildwheel with manylinux2014, centos).
Thanks for any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions