Skip to content

Commit 9dd7f07

Browse files
Build ARM and X86 wheels for macOS, linux, and windows
1 parent 6ab58cf commit 9dd7f07

5 files changed

Lines changed: 131 additions & 73 deletions

File tree

.github/actions/build/action.yml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,47 +30,8 @@ runs:
3030
requirements_doc.txt
3131
requirements.txt
3232
33-
- name: Install Linux System Deps.
34-
if: runner.os == 'Linux'
35-
shell: bash
36-
run: |
37-
sudo apt-get update
38-
sudo apt-get install -y build-essential python3-setuptools python3-tk libgtk2.0
39-
40-
- name: SWIG Install (Linux)
41-
if: runner.os == 'Linux'
42-
uses: mmomtchev/setup-swig@v4
43-
with:
44-
version: v4.2.1
45-
46-
- name: SWIG Install (macOS)
47-
if: runner.os == 'macOS'
48-
shell: bash
49-
env:
50-
HOMEBREW_NO_AUTO_UPDATE: 1
51-
HOMEBREW_NO_INSTALL_UPGRADE: 1
52-
HOMEBREW_NO_ANALYTICS: 1
53-
run: brew install swig || true
54-
55-
- name: SWIG Install (Windows)
56-
if: runner.os == 'Windows'
57-
shell: pwsh
58-
run: |
59-
$swigDir = "C:\Program Files\SWIG"
60-
if (!(Test-Path $swigDir)) {New-Item -ItemType Directory -Path $swigDir | Out-Null}
61-
$swigZip = "$swigDir\swigwin-4.2.1.zip"
62-
$swigUrl = "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download"
63-
Start-Process -NoNewWindow -Wait -FilePath "curl.exe" -ArgumentList "-L -o `"$swigZip`" `"$swigUrl`""
64-
if (!(Test-Path $swigZip) -or ((Get-Item $swigZip).Length -lt 500KB)) { Write-Host "Download failed or file is corrupted." }
65-
Expand-Archive -Path $swigZip -DestinationPath $swigDir -Force
66-
67-
- name: "Add Basilisk and SWIG paths"
68-
if: runner.os == 'Windows'
69-
shell: pwsh
70-
run: |
71-
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
72-
$newPath = “C:\Program Files\SWIG\swigwin-4.2.1;$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk”
73-
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
33+
- name: Setup system dependencies
34+
uses: ./.github/actions/setup
7435

7536
- name: Install requirements
7637
shell: bash

.github/actions/setup/action.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: setup
2+
description: >
3+
Sets up the required system dependencies to perform a Basilisk build
4+
5+
runs:
6+
using: "composite"
7+
steps:
8+
- name: Install Linux System Deps.
9+
if: runner.os == 'Linux'
10+
shell: bash
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y build-essential python3-setuptools python3-tk libgtk2.0
14+
15+
- name: SWIG Install (Linux)
16+
if: runner.os == 'Linux'
17+
uses: mmomtchev/setup-swig@v4
18+
with:
19+
version: v4.2.1
20+
21+
- name: SWIG Install (macOS)
22+
if: runner.os == 'macOS'
23+
shell: bash
24+
env:
25+
HOMEBREW_NO_AUTO_UPDATE: 1
26+
HOMEBREW_NO_INSTALL_UPGRADE: 1
27+
HOMEBREW_NO_ANALYTICS: 1
28+
run: brew install swig || true
29+
30+
- name: SWIG Install (Windows)
31+
if: runner.os == 'Windows'
32+
shell: pwsh
33+
run: |
34+
$swigDir = "C:\Program Files\SWIG"
35+
if (!(Test-Path $swigDir)) {New-Item -ItemType Directory -Path $swigDir | Out-Null}
36+
$swigZip = "$swigDir\swigwin-4.2.1.zip"
37+
$swigUrl = "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download"
38+
Start-Process -NoNewWindow -Wait -FilePath "curl.exe" -ArgumentList "-L -o `"$swigZip`" `"$swigUrl`""
39+
if (!(Test-Path $swigZip) -or ((Get-Item $swigZip).Length -lt 500KB)) { Write-Host "Download failed or file is corrupted." }
40+
Expand-Archive -Path $swigZip -DestinationPath $swigDir -Force
41+
42+
- name: "Add Basilisk and SWIG paths"
43+
if: runner.os == 'Windows'
44+
shell: pwsh
45+
run: |
46+
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
47+
$newPath = “C:\Program Files\SWIG\swigwin-4.2.1;$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk”
48+
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

.github/workflows/merge.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,6 @@ jobs:
3535
git commit -a -m "[AUTO] Bump version number" || echo "No changes"
3636
git push || true
3737
38-
build-ubuntu-latest-wheels:
39-
name: Build ubuntu-latest wheels
40-
needs: bump_version
41-
# Allow for manual runs to generate new wheels
42-
if: ${{ always() }}
43-
runs-on: ubuntu-latest
44-
strategy:
45-
matrix:
46-
python-version: ["3.9", "3.10", "3.11"]
47-
steps:
48-
- name: Checkout code
49-
uses: actions/checkout@v4
50-
51-
# The 'Build wheel' step will perform the actual build. However, we want
52-
# all pre build setup to still be performed
53-
- uses: ./.github/actions/build
54-
with:
55-
python-version: ${{ matrix.python-version }}
56-
extra-apt: "cmake"
57-
skip-build: true
58-
59-
- name: Build wheel
60-
run: |
61-
python -m pip wheel . -v --wheel-dir /tmp/wheelhouse
62-
63-
- uses: actions/upload-artifact@v4
64-
with:
65-
name: basilisk-wheels_ubuntu-22.04_python${{ matrix['python-version'] }}
66-
path: /tmp/wheelhouse/**/*asilisk*.whl
67-
6838
build_documentation:
6939
name: macOS Docs Deployment
7040
needs: bump_version
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish Wheels
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
workflow_run:
7+
workflows: ["Merge to develop"]
8+
types:
9+
- completed
10+
11+
jobs:
12+
build-wheels:
13+
name: Build Basilisk Wheels
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- macos-13 # x86_64
20+
- macos-latest # ARM64
21+
- ubuntu-latest # x86_64
22+
- ubuntu-22.04-arm # ARM64
23+
- windows-latest # x86_64
24+
25+
steps:
26+
- name: Checkout Code
27+
uses: actions/checkout@v4
28+
# Workaround for macos-13 (Intel). Ensures the conan build uses the right
29+
# SSL cert.
30+
- name: Set CA bundle (macos-13 only)
31+
if: ${{ matrix.os == 'macos-13' }}
32+
shell: bash
33+
run: |
34+
python -m pip install -U certifi
35+
CA="$(python -c 'import certifi; print(certifi.where())')"
36+
{
37+
echo "REQUESTS_CA_BUNDLE=$CA" # Python requests / Conan
38+
echo "PIP_CERT=$CA" # pip
39+
echo "SSL_CERT_FILE=$CA" # OpenSSL consumers
40+
echo "CURL_CA_BUNDLE=$CA" # curl / CMake file(DOWNLOAD)
41+
echo "CMAKE_TLS_CAINFO=$CA" # CMake
42+
} >> "$GITHUB_ENV"
43+
echo "Using CA: $CA"
44+
45+
- name: Setup system dependencies
46+
uses: ./.github/actions/setup
47+
48+
- name: Build wheels
49+
uses: pypa/cibuildwheel@v3.1.4
50+
env:
51+
CONAN_ARGS: "--opNav True --mujoco True --mujocoReplay True --recorderPropertyRollback True"
52+
53+
- name: Upload wheels
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
57+
path: ./wheelhouse/*.whl

pyproject.toml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ build-backend = "setuptools.build_meta"
33
requires = [
44
"setuptools>=70.1.0,<=78.1.0", # Required for "bdist_wheel" to work correctly.
55
"setuptools-scm>=8.0,<=8.2.1", # Automatically include all Git-controlled files in sdist
6-
"packaging>=22,<=24.2", # Due to incompatibility: https://github.com/pypa/setuptools/issues/4483
6+
"packaging",
77

88
# needed to find the numpy include headers,
99
# pin to lowest runtime allowed version to take advantage of backwards compatibility
10-
"numpy<=2.2.4,>=1.24.4",
10+
"numpy<=2.3.0,>=1.24.4",
1111

1212
# Requirements for building Basilisk through conanfile
1313
"conan>=2.0.5,<=2.15.1",
@@ -55,3 +55,25 @@ Basilisk = [
5555
[tool.setuptools.dynamic]
5656
version = {file = "docs/source/bskVersion.txt"}
5757
dependencies = {file = "requirements.txt"}
58+
59+
[tool.cibuildwheel]
60+
build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*"]
61+
skip = ["*-win32", "cp38-macosx_arm64"]
62+
build-verbosity = 1
63+
64+
[tool.cibuildwheel.environment]
65+
CMAKE_BUILD_TYPE = "Release"
66+
67+
[tool.cibuildwheel.macos.environment]
68+
MACOSX_DEPLOYMENT_TARGET = "11.0"
69+
CMAKE_OSX_DEPLOYMENT_TARGET = "11.0"
70+
71+
[tool.cibuildwheel.linux]
72+
archs = ["native"]
73+
repair-wheel-command = [
74+
"auditwheel repair --strip -w {dest_dir} {wheel}"
75+
]
76+
manylinux-x86_64-image = "manylinux_2_28"
77+
manylinux-aarch64-image = "manylinux_2_28"
78+
musllinux-x86_64-image = "musllinux_1_2"
79+
musllinux-aarch64-image = "musllinux_1_2"

0 commit comments

Comments
 (0)