Skip to content

Build wheel files in CI #11

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

Merged
merged 3 commits into from
Oct 13, 2022
Merged

Conversation

merlimat
Copy link
Contributor

Motivation

Added CI jobs to build wheel files for Mac and Linux.

Modifications

  • Simplified CMakeList.txt for easier detection of Boost-Python
  • Added PR validation to build wheels for small number of combinations
  • Added job triggered on when a tag is pushed to create all the combination of wheels for Py (3.7, 3.8, 3.9, 3.10), OS (Mac, linux glibc, linux musl) and CPU (x86_64 and arm64).
  • The wheels binaries are tested to verify no libraries/symbols are missing
  • The wheels are uploaded as artifacts for the job, so that they can later be staged for official release.

@merlimat merlimat added the build label Oct 12, 2022
@merlimat merlimat added this to the 3.0.0 milestone Oct 12, 2022
@merlimat merlimat self-assigned this Oct 12, 2022
Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use static Boost.Python library.

tar xfz boost_${BOOST_VERSION_UNDESRSCORE}.tar.gz && \
cd boost_${BOOST_VERSION_UNDESRSCORE} && \
./bootstrap.sh --with-libraries=python && \
./b2 -d0 address-model=64 cxxflags=-fPIC link=shared threading=multi variant=release install && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./b2 -d0 address-model=64 cxxflags=-fPIC link=shared threading=multi variant=release install && \
./b2 -d0 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s on purpose. The Linux build is linking to the shared libs and auditwheel will include them into the wheel archive.

It’s actually preferable to use the libpulsar.so (with all the other deps) because it will hide the symbols inside the so. If we use the .a, everything is visible and subject to symbols conflict (eg if you load another Python extension that uses this symbols)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there is a check for the resulting wheels to be loaded in a fresh container. That will protect against missing dependencies or linking errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see auditwheel includes the libboost_python.so and libpulsar.so.

(eg if you load another Python extension that uses this symbols)

But I don't understand when will this conflict happen. The deps or libpulsar.so are still statically linked. Could you explain more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway. It's not a blocker for this PR. This way works as it's protected by test. I will check the macOS build soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we link libpulsar.so, all symbols are by default hidden inside, except for the ones we want to expose (pulsar public API). This avoid conflicts if the same binary is linking with a different version of protobuf or ssl.

In the .a it’s not possible to control the symbols visibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your explanation! It's clear to me now.

I have another question that should macOS link to libpulsar.dylib as well? Currently when LINK_STATIC is ON, the libpulsar.a will be linked. And the 3rd party dependencies are all static libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is there is no “auditwheel” for Mac. Maybe we can find a way to manually add the dylib inside the wheel in the same way

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. But I think the current packaging way for macOS should be okay for now though it has the possibility for symbol conflict. BTW, I found https://pypi.org/project/delocate/ might be similar to auditwheel.

@BewareMyPower
Copy link
Contributor

LGTM. Great job!

@BewareMyPower BewareMyPower merged commit 22c6797 into apache:main Oct 13, 2022
@merlimat merlimat deleted the build-wheel-mac branch October 13, 2022 13:23
BewareMyPower added a commit to BewareMyPower/pulsar-client-python that referenced this pull request Oct 21, 2022
### Motivation

Currently the Python client cannot be built with the default apt sources
on Ubuntu 20.04, whose default CMake version is 3.16. However, even
after I installed CMake 3.24 on Ubuntu 20.04, CMake would still fail to
find Boost.Python.

### Modifications

To fix the Boost.Python not found issue, find the `Python` component
instead of `Python3` when finding Boost.

In addition, when finding Python3, find the `Development` component
instead of the `Development.Module`, which is a sub-component of
`Development`. See
https://cmake.org/cmake/help/latest/module/FindPython3.html.

After that, the minimum required CMake version becomes back to 3.12 from
3.18, which was upgraded in
apache#11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants