Skip to content

Commit

Permalink
WIP: Mac OS builds
Browse files Browse the repository at this point in the history
Apple clang is too randomly broken (no operator<=> for std::string,
seriously?), so this needs GCC.

Also, there were some non-fatal warnings about a mismatch of "deployment
target", so I figured out that I probably need to use the latest and
greatest to limit the blast size when stuff breaks. Fingers crossed;
these blind builds really take a leap of faith.

Since Apple clang is not enough and the bundled GCC is not a
cross-compiler (and I don't really feel like bootstrapping one today),
we cannot build arm64 binaries on Mac OS yet. That required another fair
amount of hoop jumping due to pypa/wheel#406 and/or
pypa/setuptools#2520.
  • Loading branch information
jktjkt committed Jul 1, 2022
1 parent 786e0b8 commit 4d797a8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 11 deletions.
92 changes: 82 additions & 10 deletions .github/workflows/ci.yaml
Expand Up @@ -40,17 +40,28 @@ jobs:
wheel: manylinux_2_31_x86_64
python-version: "3.10"

- name: "Windows 2022 MSVC Python 3.10"
os: windows-2022
triplet: x64-windows
# - name: "Windows 2022 MSVC Python 3.10"
# os: windows-2022
# triplet: x64-windows
# build_type: Release
# generators: "Visual Studio 17 2022"
# wheel: win_amd64
# python-version: "3.10"

- name: "macOS 12 x86_64 Python 3.10"
os: macos-12
build_type: Release
generators: "Visual Studio 17 2022"
wheel: win_amd64
generators: Ninja
wheel: macosx_12_0_x86_64
python-version: "3.10"

# Apple LLVM doesn't fully support C++20 (hi std::string::operator<=>),
# so we require GCC, but the prebuilt GCC on GitHub Actions virtual environment
# does not have a cross compiler. Sorry, no arm64 builds.

steps:
- name: Unix line endings in git
if: startsWith(matrix.os, 'windows')
if: startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macos')
run: |
git config --global core.autocrlf input
git config --global core.eol lf
Expand Down Expand Up @@ -132,6 +143,38 @@ jobs:
echo CC=gcc-10 >> $GITHUB_ENV
echo CXX=g++-10 >> $GITHUB_ENV
- name: GCC 11 on Mac OS
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
echo CC=gcc-11 >> $GITHUB_ENV
echo CXX=g++-11 >> $GITHUB_ENV
- name: Mac OS deployment target
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
echo MACOSX_DEPLOYMENT_TARGET=12.4 >> $GITHUB_ENV
- name: Mac OS ARCHFLAGS x86_64
if: startsWith(matrix.os, 'macos') && endsWith(matrix.wheel, '_x86_64')
shell: bash
run: |
# for libyang and libyang-cpp which are directly built via cmake
echo EXTRA_OSX_ARCH=-DCMAKE_OSX_ARCHITECTURES=x86_64 >> $GITHUB_ENV
# so that our setuptools extension knows what to pass to cmake
echo ARCHFLAGS="-arch x86_64" >> $GITHUB_ENV
# https://github.com/pypa/wheel/issues/406
echo _PYTHON_HOST_PLATFORM=$(echo ${{ matrix.wheel }} | sed 's/_/-/g') >> $GITHUB_ENV
- name: Mac OS ARCHFLAGS arm64
if: startsWith(matrix.os, 'macos') && endsWith(matrix.wheel, '_arm64')
shell: bash
run: |
echo EXTRA_OSX_ARCH=-DCMAKE_OSX_ARCHITECTURES=arm64 >> $GITHUB_ENV
echo ARCHFLAGS="-arch arm64" >> $GITHUB_ENV
echo _PYTHON_HOST_PLATFORM=$(echo ${{ matrix.wheel }} | sed 's/_/-/g') >> $GITHUB_ENV
- name: Configure Linux paths
if: startsWith(matrix.os, 'ubuntu')
shell: bash
Expand All @@ -140,6 +183,14 @@ jobs:
echo LD_LIBRARY_PATH=$(realpath -m ${{ github.workspace }}/../target/lib):$(realpath -m ${{ github.workspace }}/../target/lib64) >> $GITHUB_ENV
echo PKG_CONFIG_PATH="$(realpath -m ${{ github.workspace }}/../target)/lib/pkgconfig" >> $GITHUB_ENV
- name: Configure Mac OS paths
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
echo ${{ github.workspace }}/../target/bin >> $GITHUB_PATH
echo REPAIR_LIBRARY_PATH=${{ github.workspace }}/../target/lib >> $GITHUB_ENV
echo PKG_CONFIG_PATH=${{ github.workspace }}/../target/lib/pkgconfig >> $GITHUB_ENV
- name: Install Windows dependencies
if: >
startsWith(matrix.os, 'windows') &&
Expand All @@ -150,6 +201,10 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt install -y libpcre2-dev libcmocka-dev doctest-dev pybind11-dev ninja-build

- name: Install macOS dependencies
if: startsWith(matrix.os, 'macos')
run: brew install pcre2 cmocka doctest pybind11 ninja

- name: Fix pybind on the oldest Ubuntu
if: startsWith(matrix.os, 'ubuntu-20')
run: |
Expand All @@ -166,6 +221,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
${EXTRA_VCPKG_TARGET_TRIPLET:+${EXTRA_VCPKG_TARGET_TRIPLET}} \
${EXTRA_CMAKE_TOOLCHAIN_FILE:+${EXTRA_CMAKE_TOOLCHAIN_FILE}} \
${EXTRA_OSX_ARCH:+${EXTRA_OSX_ARCH}} \
-DENABLE_TESTS=ON \
-DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target
Expand Down Expand Up @@ -195,6 +251,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
${EXTRA_VCPKG_TARGET_TRIPLET:+${EXTRA_VCPKG_TARGET_TRIPLET}} \
${EXTRA_CMAKE_TOOLCHAIN_FILE:+${EXTRA_CMAKE_TOOLCHAIN_FILE}} \
${EXTRA_OSX_ARCH:+${EXTRA_OSX_ARCH}} \
${EXTRA_PKG_CONFIG_EXECUTABLE:+${EXTRA_PKG_CONFIG_EXECUTABLE}} \
-DCMAKE_PREFIX_PATH:PATH=${GITHUB_WORKSPACE//\\//}/../target \
-DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target
Expand Down Expand Up @@ -229,6 +286,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
${EXTRA_VCPKG_TARGET_TRIPLET:+${EXTRA_VCPKG_TARGET_TRIPLET}} \
${EXTRA_CMAKE_TOOLCHAIN_FILE:+${EXTRA_CMAKE_TOOLCHAIN_FILE}} \
${EXTRA_OSX_ARCH:+${EXTRA_OSX_ARCH}} \
${EXTRA_PKG_CONFIG_EXECUTABLE:+${EXTRA_PKG_CONFIG_EXECUTABLE}} \
-DCMAKE_PREFIX_PATH:PATH=${GITHUB_WORKSPACE//\\//}/../target \
-DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target
Expand Down Expand Up @@ -284,6 +342,15 @@ jobs:
delvewheel show '${{ github.workspace }}'/build-wheel/*.whl
delvewheel repair '${{ github.workspace }}'/build-wheel/*.whl
- name: fix the wheel, Mac OS
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
pip install delocate
DYLD_LIBRARY_PATH=${REPAIR_LIBRARY_PATH} delocate-listdeps --all '${{ github.workspace }}'/build-wheel/*.whl
DYLD_LIBRARY_PATH=${REPAIR_LIBRARY_PATH} delocate-wheel -w ${{ github.workspace }}/wheelhouse -v '${{ github.workspace }}'/build-wheel/*.whl
# https://github.com/pypa/cibuildwheel/blob/main/docs/faq.md#macos-passing-dyld_library_path-to-delocate
- name: upload the wheel
if: matrix.wheel
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -330,14 +397,19 @@ jobs:
wheel: manylinux_2_31_x86_64
python-version: "3.10"

- name: "Windows 2022 MSVC Python 3.10"
os: windows-2022
wheel: win_amd64
# - name: "Windows 2022 MSVC Python 3.10"
# os: windows-2022
# wheel: win_amd64
# python-version: "3.10"

- name: "macOS 12 x86_64 Python 3.10"
os: macos-12
wheel: macosx_12_0_x86_64
python-version: "3.10"

steps:
- name: Unix line endings in git
if: startsWith(matrix.os, 'windows')
if: startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macos')
run: |
git config --global core.autocrlf input
git config --global core.eol lf
Expand Down
2 changes: 1 addition & 1 deletion libyang-cpp

0 comments on commit 4d797a8

Please sign in to comment.