Skip to content

Commit

Permalink
Build macOS libraries from pre-built libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Jan 7, 2025
1 parent 01aaffb commit 1f16f26
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 641 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/ci-build-release-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,8 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: Dependencies cache
uses: actions/cache@v3
id: cache-deps
with:
path: .pulsar-mac-build/deps/install
key: ${{matrix.py.version_long}}-${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pkg/mac/*') }}

- name: Build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pkg/mac/build-dependencies.sh ${{matrix.py.version}} ${{matrix.py.version_long}}

- name: Pulsar C++ cache
uses: actions/cache@v3
id: cache-cpp
with:
path: .pulsar-mac-build/cpp/install
key: ${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pulsar-client-cpp-version.txt') }}-${{ hashFiles('pkg/mac/*') }}

- name: Build Pulsar C++ client
if: steps.cache-cpp.outputs.cache-hit != 'true'
run: pkg/mac/build-pulsar-cpp.sh

- name: Build and test Mac wheels
run: pkg/mac/build-mac-wheels.sh ${{matrix.py.version}}
run: pkg/mac/build-mac-wheels.sh ${{matrix.py.version}} ${{matrix.py.version_long}}

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,38 +169,9 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: Dependencies cache
uses: actions/cache@v3
id: cache-deps
with:
path: .pulsar-mac-build/deps/install
key: ${{matrix.py.version_long}}-${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pkg/mac/*') }}

- name: Build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
python3 -m venv venv
source venv/bin/activate
python3 -m pip install pyyaml setuptools
pkg/mac/build-dependencies.sh ${{matrix.py.version}} ${{matrix.py.version_long}}
- name: Pulsar C++ cache
uses: actions/cache@v3
id: cache-cpp
with:
path: .pulsar-mac-build/cpp/install
key: ${{ hashFiles('dependencies.yaml') }}-${{ hashFiles('pulsar-client-cpp-version.txt') }}-${{ hashFiles('pkg/mac/*') }}

- name: Build Pulsar C++ client
if: steps.cache-cpp.outputs.cache-hit != 'true'
run: |
source venv/bin/activate
pkg/mac/build-pulsar-cpp.sh
- name: Build and test Mac wheels
run: |
source venv/bin/activate
pkg/mac/build-mac-wheels.sh ${{matrix.py.version}}
pkg/mac/build-mac-wheels.sh ${{matrix.py.version}} ${{matrix.py.version_long}}
windows-wheels:
name: "Python ${{ matrix.python.version }} Wheel on Windows x64"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ vcpkg_installed/
lib_pulsar.so
tests/test.log
.tests-container-id.txt

include/
lib/
44 changes: 4 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ if (MSVC)
endif ()

if (LINK_STATIC)
if (MSVC)
find_library(PULSAR_LIBRARY NAMES pulsarWithDeps.lib)
else ()
find_library(PULSAR_LIBRARY NAMES libpulsar.a)
endif ()
find_library(PULSAR_LIBRARY NAMES pulsarwithdeps pulsarWithDeps.lib)
add_definitions("-DPULSAR_STATIC")
else()
elseif (NOT PULSAR_LIBRARY)
find_library(PULSAR_LIBRARY NAMES pulsar libpulsar)
endif()
message(STATUS "PULSAR_LIBRARY: ${PULSAR_LIBRARY}")
Expand Down Expand Up @@ -88,43 +84,11 @@ set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} Python3::Module)
message(STATUS "All libraries: ${PYTHON_WRAPPER_LIBS}")

if (LINK_STATIC AND NOT MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")

# We need to include all the static libs individually because we cannot easily create a universal2 libpulsar.a
# with all the deps included.
find_package(OpenSSL REQUIRED)
message("OPENSSL_LIBRARIES: " ${OPENSSL_LIBRARIES})

find_package(Protobuf REQUIRED)
message("Protobuf_LIBRARIES: " ${Protobuf_LIBRARIES})

find_package(curl REQUIRED)
message("CURL_LIBRARIES: " ${CURL_LIBRARIES})

find_package(zlib)
message("ZLIB_LIBRARIES: " ${ZLIB_LIBRARIES})

find_library(LIB_ZSTD NAMES libzstd.a)
message(STATUS "ZStd: ${LIB_ZSTD}")
find_library(LIB_SNAPPY NAMES libsnappy.a)
message(STATUS "LIB_SNAPPY: ${LIB_SNAPPY}")

set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS}
${OPENSSL_LIBRARIES}
${Protobuf_LIBRARIES}
${ZLIB_LIBRARIES}
${LIB_ZSTD}
${LIB_SNAPPY}
${CURL_LIBRARIES}
)

if (APPLE)
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
target_link_libraries(_pulsar -Wl,-all_load ${PYTHON_WRAPPER_LIBS})
target_link_libraries(_pulsar ${PYTHON_WRAPPER_LIBS})
else ()
if (NOT MSVC)
set (CMAKE_SHARED_LINKER_FLAGS " -static-libgcc -static-libstdc++")
endif()
set (CMAKE_SHARED_LINKER_FLAGS " -static-libgcc -static-libstdc++")
target_link_libraries(_pulsar ${PYTHON_WRAPPER_LIBS})
endif ()
elseif (LINK_STATIC) # MSVC
Expand Down
23 changes: 0 additions & 23 deletions build-support/dep-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,15 @@ download_dependency() {
VERSION=$(grep $DEP $DEP_FILE | sed 's/://' | awk '{print $2}')

case $DEP in
"cmake")
URL=https://github.com/Kitware/CMake/releases/download/v${VERSION}/cmake-${VERSION}-linux-${ARCH}.tar.gz
;;
"pulsar-cpp")
URL=$(pulsar_cpp_base_url $VERSION)/apache-pulsar-client-cpp-${VERSION}.tar.gz
;;
"pybind11")
URL=https://github.com/pybind/pybind11/archive/refs/tags/v${VERSION}.tar.gz
;;
"boost")
VERSION_UNDERSCORE=$(echo $VERSION | sed 's/\./_/g')
URL=https://github.com/boostorg/boost/archive/refs/tags/boost-${VERSION}.tar.gz
;;
"protobuf")
URL=https://github.com/google/protobuf/releases/download/v${VERSION}/protobuf-cpp-${VERSION}.tar.gz
;;
"zlib")
URL=https://github.com/madler/zlib/archive/v${VERSION}.tar.gz
;;
"zstd")
URL=https://github.com/facebook/zstd/releases/download/v${VERSION}/zstd-${VERSION}.tar.gz
;;
"snappy")
URL=https://github.com/google/snappy/archive/refs/tags/${VERSION}.tar.gz
;;
"openssl")
URL=https://github.com/openssl/openssl/archive/OpenSSL_$(echo $VERSION | sed 's/\./_/g').tar.gz
;;
"curl")
VERSION_UNDERSCORE=$(echo $VERSION | sed 's/\./_/g')
URL=https://github.com/curl/curl/releases/download/curl-${VERSION_UNDERSCORE}/curl-${VERSION}.tar.gz
;;
*)
echo "Unknown dependency $DEP for version $VERSION"
exit 1
Expand Down
8 changes: 1 addition & 7 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
# under the License.
#

cmake: 3.24.2
pulsar-cpp: 3.7.0
pybind11: 2.10.1
boost: 1.80.0
protobuf: 3.20.0
zlib: 1.2.13
zstd: 1.5.2
snappy: 1.1.9
# The OpenSSL dependency is only used when building Python from source
openssl: 1.1.1q
curl: 8.4.0
Loading

0 comments on commit 1f16f26

Please sign in to comment.