Closed AlvinSchiller closed 2 months ago
building pyzmq 26 from source requires cmake. If you don't have cmake, there is a Python cmake
package that will fetch cmake as a wheel, but if there isn't a wheel for your platform, you need cmake installed separately. It looks like you should be getting this one, I'm not sure how piwheels works, though.
This is the biggest downside of the new build system, and there's nothing really that can be done about it until someone can address https://github.com/scikit-build/cmake-python-distributions/issues/33. If you have the ability to install cmake, that's what is required.
I believe #1977 fixed the issue preventing the piwheels builds of pyzmq 26, I'll do 26.0.1 with that tonight or tomorrow.
Hello, there seem to be an issue, many builds are missing from https://pypi.org/project/pyzmq/26.0.1/#files , especially amd64 build, which were present in https://pypi.org/project/pyzmq/26.0.0/#files
The CI upload took a while today, should be all there now.
The 26.0.2 builds appeared to work fine on piwheels: https://www.piwheels.org/project/pyzmq/
The problem on bullseye appears to be that cmake 3.29.x has no wheel package for python 3.9 for arm, so the installation fails. It works with cmake 3.28.x though. https://www.piwheels.org/project/cmake/json/ Seems to be a problem on there side.
Opened https://github.com/scikit-build/cmake-python-distributions/issues/494
With 26.0.2 we have a new problem on Bookworm now.
The installation works, but a python call for a version check after fails, with the prebuild libzmq.
Using the bundled
libzmq succeeds.
local zmq_version=$(python -c 'import zmq; print(f"{zmq.zmq_version()}")')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/__init__.py", line 52, in <module>
from zmq import backend
File "/home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/__init__.py", line 30, in <module>
raise original_error from None
File "/home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/__init__.py", line 25, in <module>
_ns = select_backend(first)
^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/select.py", line 31, in select_backend
mod = import_module(name)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
from . import _zmq
ImportError: /home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/cython/_zmq.cpython-311-arm-linux-gnueabihf.so: undefined symbol: zmq_msg_set_routing_id
Do you have a link to build commands, context, and output? This is what you would get e.g. if you built against libzmq with drafts but the at runtime found a different libzmq built without drafts. It might be missing rpath in your link flags.
We build libzmq and pyzmq like this (as described here)
JUKEBOX_ZMQ_TMP_DIR="${HOME_PATH}/libzmq"
JUKEBOX_ZMQ_PREFIX="/usr/local"
JUKEBOX_ZMQ_VERSION="4.3.5"
_build_libzmq_pyzmq_with_drafts() {
local zmq_filename="zeromq-${JUKEBOX_ZMQ_VERSION}"
local zmq_tar_filename="${zmq_filename}.tar.gz"
local cpu_count=${CPU_COUNT:-$(python3 -c "import os; print(os.cpu_count())")}
cd "${JUKEBOX_ZMQ_TMP_DIR}"
wget --quiet https://github.com/zeromq/libzmq/releases/download/v${JUKEBOX_ZMQ_VERSION}/${zmq_tar_filename}
tar -xzf ${zmq_tar_filename}
rm -f ${zmq_tar_filename}
cd ${zmq_filename}
./configure --prefix=${JUKEBOX_ZMQ_PREFIX} --enable-drafts --disable-Werror
make -j${cpu_count} && sudo make install
ZMQ_PREFIX="${JUKEBOX_ZMQ_PREFIX}" ZMQ_DRAFT_API=1 pip install -v pyzmq --no-binary pyzmq
}
Note: This problem existed most likely already with v26.0.0 but pops up only at runtime. We added this version check just recently, so it now pops up directly in the ci run.
Can you add sudo ldconfig
between installing libzmq and building pyzmq? Not sure if it would help, but worth a try.
it would also help to have the full build output of pyzmq, just to see what libzmq it is finding, as well as ldd
output for the .so file in pyzmq.
based on the output, it really seems like pyzmq is built with a libzmq with drafts, but a different libzmq is being found at runtime. Check if there is more than one on your system. It may be that you need to add rpath arguments if there’s more than one (ldconfig might also help with this) to ensure that the right one is loaded.
Adding sudo ldconfig
didn't make a difference.
Here is the build log for pyzmq from the ci
And the ldd
output for /home/testuser/RPi-Jukebox-RFID/.venv/lib/python3.11/site-packages/zmq/backend/cython/_zmq.cpython-311-arm-linux-gnueabihf.so
I added some output and apparently the system has libzmq already installed in a different version, which would support your statement that the wrong lib is linked.
$apt list --installed | grep "zmq"
libzmq5/stable,now 4.3.4-6 armhf [installed,automatic]
If the installation is run on a real pi, no libzmq version is installed by default, so the output is like this instead:
$ python -c 'import zmq; print(f"{zmq.zmq_version()}")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/pi/testenv/lib/python3.11/site-packages/zmq/__init__.py", line 52, in <module>
from zmq import backend
File "/home/pi/testenv/lib/python3.11/site-packages/zmq/backend/__init__.py", line 30, in <module>
raise original_error from None
File "/home/pi/testenv/lib/python3.11/site-packages/zmq/backend/__init__.py", line 25, in <module>
_ns = select_backend(first)
^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/testenv/lib/python3.11/site-packages/zmq/backend/select.py", line 31, in select_backend
mod = import_module(name)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/testenv/lib/python3.11/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
from . import _zmq
ImportError: libzmq.so.5: cannot open shared object file: No such file or directory
$ ldd testenv/lib/python3.11/site-packages/zmq/backend/cython/_zmq.cpython-311-arm-linux-gnueabihf.so
linux-vdso.so.1 (0x7ef38000)
/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76ea0000)
libzmq.so.5 => not found
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76d20000)
/lib/ld-linux-armhf.so.3 (0x76efb000)
Here sudo ldconfig
seems to fix the situation, if a prebuild libzmq is used.
Can you add
export LDFLAGS="-Wl,-rpath,/usr/local/lib"
export SKBUILD_CMAKE_VERBOSE=true
and share the output again?
EDIT: added missing /lib
on rpath
Can you add
export LDFLAGS="-Wl,-rpath,/usr/local" export SKBUILD_CMAKE_VERBOSE=true
and share the output again?
and is the result still the same for ldd ldd testenv/lib/python3.11/site-packages/zmq/backend/cython/_zmq.*.so
?
Ah sry, yes looks the same
I have created a testrepo running the build commands in an action, to better test this without clutter. @minrk I have invited you to collaborate, so you can see the build logs, and feel free to test on new branches.
Here are the things i observed:
Why is ldconfig
needed after all? From the log output of the libzmq build, it looks like this is already done?
But i am not familiar with this build processes or this commands.
...
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
...
Adding the ldconfig
call works in this test repo, but not in the original. I have compared the output of ldconfig
and it looks like that the linking is done with the first appearence in the paths. This would explain the different outcomes in different systems.
(I have removed the vast majority of other lib to make it readable and marked the libmzq
entries to show what i mean.)
EDIT: I can reproduce this manually on a Raspberry Pi 2 W with Raspi OS Bookworm lite 32-bit installed.
I have build libzmq, executed the ldconfig command and build pyzmq like described above.
If libzmq5 is not installed via apt, the command python -c 'import zmq; print(f"{zmq.zmq_version()}")'
succeeds.
If libzmq5 is installed via apt (even afterwards), the command fails.
Using a "custom" prefix does not work, see the branch test/prefix in the testrepo. Thought the build finds the correct location for libzmq, the linking seems to use another logic for the path and doesn't respect the given prefix.
...
-- Looking for libzmq in /etc/libzmq
> -- Looking for libzmq in /etc/libzmq - /etc/libzmq/lib/libzmq.so
-- Using Python Python /opt/hostedtoolcache/Python/3.11.9/x64/bin/python
-- Building Cython backend
> -- Linking libzmq target libzmq
...
Why is ldconfig needed after all?
See this answer.
This is unrelated to pyzmq, but ld itself. ld has a cache, so you may need to run ldconfig to refresh its cache after installing a new library, especially when you already have another version of the same library at a lower priority on ld's path.
Using a "custom" prefix does not work, see the branch test/prefix in the testrepo.
"Custom" prefix usually needs to be combined with setting the runtime path (rpath), e.g -Wl,-rpath,$ZMQ_PREFIX/lib
, as demonstrated here, and shown to be working here.
I made a mistake in my suggestion where I specified the prefix (-Wl,-rpath,$ZMQ_PREFIX
), which should have been the library dir (-Wl,-rpath,$ZMQ_PREFIX/lib
).
It's arguable whether this should be done by pyzmq by default or not, because it doesn't seem to be standard practice for other packages to do this, but I did used to do it in setup.py, so I've put it back in #1983.
Thanks a lot for the help and clearing this out!
Using the changed prefix path -Wl,-rpath,${ZMQ_PREFIX}/lib
finally fixed the situation on bookworm!
I wasn't aware of this commands as i have only little knowledge with building and honestly just followed the documentation on how to build pyzmq with libzmq draft support.
For me personally it would just be fine to add this to the documentation, so c&p gets it working. :)
The original issue still persists, but is not caused from this project (see comment), so closing this.
Thanks again!
What pyzmq version?**
26.0.0
What libzmq version?**
4.3.5 (seperatly build and installed)
Python version (and how it was installed)
python 3.9 via apt-get
OS
Raspberry Pi OS Bullseye 32-bit / Github CI Docker Debian Bullseye
What happened?
In our projekt we build pyzmq from sources with a seperatly prebuild libzmq installation. Prior to the v26.0.0 release this succeeded on Bullseye and Bookworm. Since the new version release this fails on Bullseye.
Traceback, if applicable
More info
libzmq prebuild and copied to "/usr/local".
Build pyzmq ZMQ_PREFIX="/usr/local" ZMQ_DRAFT_API=1 pip install -v pyzmq --no-binary pyzmq
We had also problems with the prerelease some time ago: https://github.com/zeromq/pyzmq/issues/1937