Skip to content

Commit

Permalink
Build macOS x86_64 Python wheels with macOS 14 (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored May 2, 2024
1 parent 36134e3 commit 07030f2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 24 deletions.
85 changes: 66 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,85 @@ jobs:
strategy:
fail-fast: false
matrix:
# Windows, Linux, macOS x86_64, macOS arm64
os: [windows-2022, ubuntu-22.04, macOS-13, macOS-14]

name: "${{ matrix.os }} - native"
include:
- name: Windows x86_64
os: windows-2022
cmake-args:
- name: Linux x86_64
os: ubuntu-22.04
cmake-args:
- name: macOS universal
os: macOS-14
cmake-args: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"

name: ${{ matrix.name }} - native
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- run: cmake -B build -S . -DBUILD_EXAMPLES=ON
- run: cmake -B build -S . -DBUILD_EXAMPLES=ON ${{ matrix.cmake-args }}
- run: cmake --build build --config RelWithDebInfo --parallel $(nproc)
- run: ctest -C RelWithDebInfo --output-on-failure
working-directory: build
- run: cmake --install build --config RelWithDebInfo --prefix pkg

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} - native
name: ${{ matrix.name }} - native
path: pkg

build-python-wheel:
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
# Windows, Linux, macOS x86_64, macOS arm64
os: [windows-2022, ubuntu-22.04, macOS-13, macOS-14]
version: ['3.9', '3.10', '3.11', '3.12']
exclude:
- os: macOS-14
version: '3.9'

name: "${{ matrix.os }} - Python ${{ matrix.version }} wheel"
include:
- name: Windows x86_64
os: windows-2022
version: "3.9"
cmake-env:
- name: Windows x86_64
os: windows-2022
version: "3.10"
cmake-env:
- name: Windows x86_64
os: windows-2022
version: "3.11"
cmake-env:
- name: Windows x86_64
os: windows-2022
version: "3.12"
cmake-env:
- name: Linux x86_64
os: ubuntu-22.04
version: "3.9"
cmake-env:
- name: Linux x86_64
os: ubuntu-22.04
version: "3.10"
cmake-env:
- name: Linux x86_64
os: ubuntu-22.04
version: "3.11"
cmake-env:
- name: Linux x86_64
os: ubuntu-22.04
version: "3.12"
cmake-env:
- name: macOS universal
os: macOS-14
version: "3.10"
cmake-env: CMAKE_OSX_ARCHITECTURES="x86_64;arm64"
- name: macOS universal
os: macOS-14
version: "3.11"
cmake-env: CMAKE_OSX_ARCHITECTURES="x86_64;arm64"
- name: macOS universal
os: macOS-14
version: "3.12"
cmake-env: CMAKE_OSX_ARCHITECTURES="x86_64;arm64"

name: ${{ matrix.name }} - Python ${{ matrix.version }} wheel
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -56,21 +103,21 @@ jobs:

- run: python3 ./tools/update_version.py
- run: pip3 install build tox
- run: python3 -m build --wheel
- run: ${{ matrix.cmake-env }} python3 -m build --wheel
- run: python3 ../.github/workflows/repair_wheel.py sleipnirgroup_jormungandr-*.whl
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS')
working-directory: dist
- run: python3 -m tox -e ${{ matrix.version }}

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} - Python ${{ matrix.version }} wheel
name: ${{ matrix.name }} - Python ${{ matrix.version }} wheel
path: dist

build-python-sdist:
timeout-minutes: 10

name: "Python sdist"
name: Python sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -123,7 +170,7 @@ jobs:
container: wpilib/roborio-cross-ubuntu:2024-22.04
toolchain: /usr/local/toolchain-config.cmake

name: "${{ matrix.artifact-name }}"
name: ${{ matrix.artifact-name }}
runs-on: ubuntu-22.04
container: ${{ matrix.container }}
steps:
Expand All @@ -139,7 +186,7 @@ jobs:
path: pkg

build-wasm:
name: "Wasm"
name: Wasm
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions jormungandr/test/autodiff/hessian_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def test_product_of_sines():

# y = prod(sin(x))
y = prod(x.cwise_transform(autodiff.sin))
assert y.value() == math.sin(1) * math.sin(2) * math.sin(3) * math.sin(
4
) * math.sin(5)
assert y.value() == pytest.approx(
math.sin(1) * math.sin(2) * math.sin(3) * math.sin(4) * math.sin(5), abs=1e-15
)

g = Gradient(y, x)
for i in range(x.rows()):
Expand Down
5 changes: 3 additions & 2 deletions test/src/autodiff/HessianTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ TEST_CASE("Hessian - Product of sines", "[Hessian]") {
auto temp = x.CwiseTransform(sleipnir::sin);
auto y = std::accumulate(temp.begin(), temp.end(), sleipnir::Variable{1.0},
std::multiplies{});
CHECK(y.Value() ==
std::sin(1) * std::sin(2) * std::sin(3) * std::sin(4) * std::sin(5));
CHECK(y.Value() == Catch::Approx(std::sin(1) * std::sin(2) * std::sin(3) *
std::sin(4) * std::sin(5))
.margin(1e-15));

auto g = sleipnir::Gradient(y, x);
for (int i = 0; i < x.Rows(); ++i) {
Expand Down

0 comments on commit 07030f2

Please sign in to comment.