Skip to content

Commit

Permalink
Add macos arm binary wheels (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmloose authored Sep 6, 2024
1 parent fc6c7b0 commit 73cf8f6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-12]
os: [ubuntu-latest, macos-12, macos-14]
toolchain:
- {compiler: gcc, version: 12}
include:
- os: macos-12
macosx_deployment_target: "12.0"
- os: macos-14
macosx_deployment_target: "14.0"

steps:
- uses: actions/checkout@v4
with:
# Needed for `setuptools-scm`
fetch-depth: 0
fetch-depth: 0 # needed for versioning with `setuptools-scm`

- name: Setup Fortran
uses: fortran-lang/setup-fortran@v1
Expand All @@ -37,45 +41,47 @@ jobs:
- name: Build wheels
uses: pypa/[email protected]
env:
MACOSX_DEPLOYMENT_TARGET: "12.0"
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}

- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for versioning with `setuptools-scm`

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: tarball
path: dist/*.tar.gz

upload_pypi:
name: Publish on PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# Upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# Alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/[email protected]
path: dist # put artifacts where next action expects them to be
merge-multiple: true
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
skip-existing: true
# To test:
# repository-url: https://test.pypi.org/legacy/
# password: ${{ secrets.test_pypi_password }}
17 changes: 9 additions & 8 deletions cibuildwheel/before_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# This script should be called by `cibuildwheel` in the `before-build` stage.
#
# This script will first install the oldest supported `numpy` to maximize
# portability. Next the Boost Python libraries will be built from source,
# This script will first install the latest `numpy` 1.x version (2.x is not
# supported yet). Next the Boost Python libraries will be built from source,
# including the bindings to NumPy. The Boost sources must be in the directory
# `${BOOST_BUILD_DIR}/boost`. The libraries will be installed in the directory
# `${BOOST_INSTALL_DIR}`. Both environment variables must have been set.
Expand All @@ -15,10 +15,10 @@ function cleanup
rm -rf "${BOOST_INSTALL_DIR}"
}

# Install oldest supported numpy
# Install latest numpy 1.x; we do not yet support numpy 2.x
function install_numpy
{
pip install oldest-supported-numpy
pip install 'numpy<2'
}

# Build the Boost Python libraries
Expand All @@ -27,10 +27,11 @@ function build_boost_python
nproc=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())')
inc_dir=$(python -c 'import sysconfig as sc; print(sc.get_path("include"))')
cd "${BOOST_BUILD_DIR}/boost"
./bootstrap.sh --prefix="${BOOST_INSTALL_DIR}" \
--with-libraries=python \
--with-toolset=gcc
./b2 -j"${nproc}" \
./bootstrap.sh \
--prefix="${BOOST_INSTALL_DIR}" \
--with-toolset=gcc \
--with-libraries=python
./b2 -j"${nproc}" -d0 \
cxxflags="-fPIC -I${inc_dir}" \
link=static,shared \
install
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [
"cmake>=3.18",
"meson",
"ninja",
"oldest-supported-numpy",
"numpy<2",
"scikit-build>=0.13",
"setuptools",
"setuptools<65; python_version<'3.12'",
Expand Down Expand Up @@ -76,10 +76,10 @@ Documentation = "https://pybdsf.readthedocs.io"
[tool.cibuildwheel]
before-all = "cibuildwheel/before_all.sh"
before-build = "cibuildwheel/before_build.sh"
build = "cp3{8,9,10,11,12}-*_x86_64"
build = "cp3{8,9,10,11,12}-*"
build-verbosity = 1
environment = """ \
BOOST_VERSION="1.81.0" \
BOOST_VERSION="1.85.0" \
BOOST_BUILD_DIR="/tmp/boost-build" \
BOOST_INSTALL_DIR="${HOME}/boost" \
BOOST_ROOT="${BOOST_INSTALL_DIR}" \
Expand All @@ -98,7 +98,7 @@ repair-wheel-command = """\
"""

[tool.cibuildwheel.linux]
skip = ["*-musllinux_*"]
skip = ["*-musllinux_*", "*_i686"]


###########################
Expand Down

0 comments on commit 73cf8f6

Please sign in to comment.