pulsar
pulsar copied to clipboard
[Client][python] Build Python client for Windows
Search before asking
- [X] I searched in the issues and found nothing similar.
Motivation
I try to build cpp client with static
flag, and it seems that link progress will be fail.
Here is my pr: https://github.com/apache/pulsar/pull/17507/files
cmake \
-B ./build-1 \
-G "${{ matrix.generator }}" ${{ matrix.arch }} \
-DBUILD_PYTHON_WRAPPER=ON -DBUILD_TESTS=OFF \
-DVCPKG_TRIPLET=${{ matrix.triplet }} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_STATIC_LIB=ON \
-S .
The workflow run is here:
https://github.com/apache/pulsar/runs/8223165825?check_suite_focus=true#step:12:239
Maybe we need to fix CMakeLists.txt to support the compile.
Solution
No response
Alternatives
No response
Anything else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
The root cause might be
LINK : fatal error LNK1104: cannot open file 'python310.lib' [D:\a\pulsar\pulsar\pulsar-client-cpp\build-1\python_pulsar.vcxproj]
Pulsar Python client build requires a Python library installed on Windows. Could you help set up the Python in the workflow file? @yaalsn
I think we might also need to add python
to the vcpkg.json.
I have confirmed again, the python3
dependency has already been added to vcpkg.json
in your PR, I think it might be something wrong with the CMakeLists.txt
.
I checked this issue today. It requires the changes to CMakeLists.txt because the dynamic library of Python client (_pulsar.so
) should be linked statically, i.e. with the -DLINK_STATIC=ON
CMake option. Unfortunately, when LINK_STATIC
option is enabled, it only tries to find the *.a
library, which is a static library in Linux and macOS, as the static library, while it should also be *.lib
on Windows. See https://github.com/apache/pulsar/blob/8441f6724b1aa502df580518ae14f0c559f53547/pulsar-client-cpp/CMakeLists.txt#L144
BTW, @yaalsn your CI workflow is wrong. The BUILD_STATIC_LIB
option means building a static library of Pulsar, but the LINK_STATIC
option means the Pulsar library, which could be either static or dynamic, links to a static library.
For Linux build:
-
BUILD_STATIC_LIB=ON
:libpulsar.a
will be generated -
LINK_STATIC=ON
: Iflibpulsar.so
orlibpulsar.a
is generated, the dependencies are statically linked. For example, for the libcurl dependency,libcurl.a
is linked (just in compile time because it's statically linked) whilelibcurl.so
is not used.
I'm working on this issue in my own branch: https://github.com/BewareMyPower/pulsar/commits/bewaremypower/cpp-static-link. Now the Pulsar libraries can be built successfully on MSVC with LINK_STATIC=ON
, but the Python build still failed. I will continue fixing it.
@BewareMyPower Thanks for your help!
The issue had no activity for 30 days, mark with Stale label.