Skip to content
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

Windows builds #7

Closed
Diggsey opened this issue Oct 4, 2022 · 1 comment · Fixed by #23
Closed

Windows builds #7

Diggsey opened this issue Oct 4, 2022 · 1 comment · Fixed by #23

Comments

@Diggsey
Copy link

Diggsey commented Oct 4, 2022

Any possibility of getting windows support for the Pulsar python package?

I've tried building it localy and got pretty far, but ran into issues with matching the python version between boost-python and pulsar-client-python, which I've been unable to resolve.

The C++ client itself builds fine on windows, so I don't think there should be any serious blockers for this?

@BewareMyPower
Copy link
Contributor

I don't think there should be any serious blockers

Actually yes. The CMakeLists.txt needs some fixes. I was working on this issue a few days ago and will continue the fix after backing to work. The core issue is about the static linking.

Here is my working branch: https://github.com/BewareMyPower/pulsar/commits/bewaremypower/cpp-static-link. Please note that it doesn't work currently (I forgot to push latest commits in my Windows laptop).

  1. The binary suffix should be .pyd on Windows (in my branch it's .dll, which is wrong)
  2. The Python library should not be linked statically when building _pulsar.pyd.

BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Oct 27, 2022
Fixes apache#7

### Motivation

The Python client cannot be built with MSVC.

### Modifications

Add `vcpkg.json` to download the Boost.Python dependency.
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Oct 27, 2022
Fixes apache#7

### Motivation

The Python client cannot be built with MSVC.

### Modifications

Add `vcpkg.json` to download the Boost.Python dependency. Then fix some
CMake errors:
1. Boost.Python cannot be found on Windows. The component of Boost
   cannot be `python3`. It should be a specific version like
   `python310`.
2. Link to `pulsarWithDeps.lib` for MSVC and modify the compilation
   option from `/MD` to `/MT` when `LINK_STATIC` is `ON`.
3. When `LINK_STATIC` is `OFF` (by default), remove the suffix of the
   name because CMake will find the correct suffixes on different
   platforms.
4. Add the Python3 library to the target on Windows, otherwise the
   symbols cannot be found.

Since Python on Windows can only recognize `*.pyd` suffix of a C
extension, change the `CMAKE_SHARED_LIBRARY_SUFFIX` and use
`_pulsar.pyd` in `setup.py` on Windows.

Add README to tell users how to build Python client on Windows.

### TODO

Add a GitHub Actions workflow to verify the Windows build.
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Oct 27, 2022
Fixes apache#7

### Motivation

The Python client cannot be built with MSVC.

### Modifications

Add `vcpkg.json` to download the Boost.Python dependency. Then fix some
CMake errors:
1. Boost.Python cannot be found on Windows. The component of Boost
   cannot be `python3`. It should be a specific version like
   `python310`.
2. Link to `pulsarWithDeps.lib` for MSVC and modify the compilation
   option from `/MD` to `/MT` when `LINK_STATIC` is `ON`.
3. When `LINK_STATIC` is `OFF` (by default), remove the suffix of the
   name because CMake will find the correct suffixes on different
   platforms.
4. Add the Python3 library to the target on Windows, otherwise the
   symbols cannot be found.

Since Python on Windows can only recognize `*.pyd` suffix of a C
extension, change the `CMAKE_SHARED_LIBRARY_SUFFIX` and use
`_pulsar.pyd` in `setup.py` on Windows.

Add README to tell users how to build Python client on Windows.

### TODO

Add a GitHub Actions workflow to verify the Windows build.
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Nov 1, 2022
Fixes apache#7

The Python client cannot be built with MSVC.

CMakeLists.txt:
1. Boost.Python cannot be found on Windows. The component of Boost
   cannot be `python3`. It should be a specific version like
   `python310`. Therefore, find all possible components from 3.10 to 3.7
   until the first component is available.
2. For MSVC, link to `pulsarWithDeps.lib` when `LINK_STATIC` is `ON` and
   set the `MSVC_RUNTIME_LIBRARY` target property to `MultiThreaded`.
3. Change the suffix from `.so` to `.pyd` because Python on Windows
   recognizes `*.pyd` as the dynamic library.
4. Link to Python library with MSVC, otherwise the symbos cannot be
   found when linking `boost-python`.

README: tell users how to build Python client on Windows.

Add a workflow to build Python wheels of versions 3.7 to 3.10 on Windows
and verify the build will succeed.

With this PR, Windows users still need to put the related
`boost_python*.dll` under the system path. In future, the `boost-python`
dependency will be removed. See
apache#24.
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Nov 1, 2022
Fixes apache#7

The Python client cannot be built with MSVC.

CMakeLists.txt:
1. Boost.Python cannot be found on Windows. The component of Boost
   cannot be `python3`. It should be a specific version like
   `python310`. Therefore, find all possible components from 3.10 to 3.7
   until the first component is available.
2. For MSVC, link to `pulsarWithDeps.lib` when `LINK_STATIC` is `ON` and
   set the `MSVC_RUNTIME_LIBRARY` target property to `MultiThreaded`.
3. Change the suffix from `.so` to `.pyd` because Python on Windows
   recognizes `*.pyd` as the dynamic library.
4. Link to Python library with MSVC, otherwise the symbos cannot be
   found when linking `boost-python`.

README: tell users how to build Python client on Windows.

Add a workflow to build Python wheels of versions 3.7 to 3.10 on Windows
and verify the build will succeed.

With this PR, Windows users still need to put the related
`boost_python*.dll` under the system path. In future, the `boost-python`
dependency will be removed. See
apache#24.
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this issue Nov 1, 2022
Fixes apache#7

The Python client cannot be built with MSVC.

CMakeLists.txt:
1. Boost.Python cannot be found on Windows. The component of Boost
   cannot be `python3`. It should be a specific version like
   `python310`. Therefore, find all possible components from 3.10 to 3.7
   until the first component is available.
2. For MSVC, link to `pulsarWithDeps.lib` when `LINK_STATIC` is `ON` and
   set the `MSVC_RUNTIME_LIBRARY` target property to `MultiThreaded`.
3. Change the suffix from `.so` to `.pyd` because Python on Windows
   recognizes `*.pyd` as the dynamic library.
4. Link to Python library with MSVC, otherwise the symbos cannot be
   found when linking `boost-python`.

README: tell users how to build Python client on Windows.

Add a workflow to build Python wheels of versions 3.7 to 3.10 on Windows
and verify the build will succeed.

With this PR, Windows users still need to put the related
`boost_python*.dll` under the system path. In future, the `boost-python`
dependency will be removed. See
apache#24.
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

Successfully merging a pull request may close this issue.

2 participants