Skip to content

[Client][python] Build Python client for Windows #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
yaalsn opened this issue Sep 9, 2022 · 8 comments
Closed
1 of 2 tasks

[Client][python] Build Python client for Windows #29

yaalsn opened this issue Sep 9, 2022 · 8 comments
Assignees

Comments

@yaalsn
Copy link
Contributor

yaalsn commented Sep 9, 2022

Search before asking

  • 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!
@BewareMyPower
Copy link
Contributor

BewareMyPower commented Sep 15, 2022

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.

@BewareMyPower
Copy link
Contributor

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.

@BewareMyPower BewareMyPower changed the title [Client][CPP] Python client for Windows [Client][python] Build Python client for Windows Sep 15, 2022
@BewareMyPower
Copy link
Contributor

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: If libpulsar.so or libpulsar.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) while libcurl.so is not used.

@BewareMyPower
Copy link
Contributor

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.

@yaalsn
Copy link
Contributor Author

yaalsn commented Sep 23, 2022

@BewareMyPower Thanks for your help!

@github-actions
Copy link

The issue had no activity for 30 days, mark with Stale label.

@tisonkun tisonkun transferred this issue from apache/pulsar Nov 9, 2022
@tisonkun
Copy link
Member

tisonkun commented Nov 9, 2022

Moved to the dedicated repository.

@BewareMyPower
Copy link
Contributor

Closed by #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants