Skip to content

Commit 712b3f0

Browse files
authored
Merge pull request aleaxit#470 from skirpichev/try-macos-13
Use macos-14 to build and test arm64 wheels
2 parents eb8dfcb + df7277d commit 712b3f0

File tree

9 files changed

+98
-152
lines changed

9 files changed

+98
-152
lines changed

.github/workflows/build_wheels.yml

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,35 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-latest, macos-latest]
12-
11+
os: [ubuntu-22.04, macos-12, macos-14]
1312
steps:
14-
- uses: actions/checkout@v3
15-
13+
- uses: actions/checkout@v4
14+
- if: runner.os == 'macOS'
15+
run: brew install pipx
1616
- name: Build wheels
17-
uses: pypa/[email protected].0
17+
uses: pypa/[email protected].5
1818
env:
1919
CIBW_PRERELEASE_PYTHONS: True
2020
CIBW_SKIP: pp*
21-
CIBW_BEFORE_BUILD: bash scripts/before_ci_build.sh
21+
CIBW_BEFORE_BUILD: bash scripts/cibw_before_all.sh
2222
CIBW_TEST_EXTRAS: tests
23+
CIBW_TEST_SKIP: cp38-macosx_arm64
2324
CIBW_TEST_COMMAND: >
2425
pytest {package}/test/ &&
2526
python {package}/test_cython/runtests.py
26-
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
27-
bash scripts/repair_ci_wheel.sh {dest_dir} {wheel}
28-
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
29-
bash scripts/repair_ci_wheel.sh {dest_dir} {wheel} {delocate_archs}
30-
31-
- uses: actions/upload-artifact@v3
27+
CIBW_REPAIR_WHEEL_COMMAND: >
28+
bash scripts/cibw_repair_wheel_command.sh {dest_dir} {wheel}
29+
- uses: actions/upload-artifact@v4
3230
with:
33-
name: wheels
34-
path: ./wheelhouse
35-
36-
build_wheels_macos_arm64:
37-
name: Build wheel on ${{ matrix.os }} arm64
38-
runs-on: ${{ matrix.os }}
39-
strategy:
40-
matrix:
41-
os: [macos-12]
42-
31+
name: wheels-${{ matrix.os }}
32+
path: ./wheelhouse/
33+
merge:
34+
runs-on: ubuntu-22.04
35+
needs: build_wheels
4336
steps:
44-
- uses: actions/checkout@v3
45-
46-
- name: Build wheel
47-
uses: pypa/[email protected]
48-
env:
49-
CIBW_PRERELEASE_PYTHONS: True
50-
CIBW_BEFORE_BUILD: bash scripts/before_ci_build_apple_silicon.sh
51-
CIBW_SKIP: pp*
52-
CIBW_ARCHS_MACOS: arm64
53-
CIBW_TEST_EXTRAS: tests
54-
CIBW_TEST_COMMAND: >
55-
pytest {package}/test/ &&
56-
python {package}/test_cython/runtests.py
57-
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
58-
bash scripts/repair_ci_wheel.sh {dest_dir} {wheel} {delocate_archs}
59-
60-
- uses: actions/upload-artifact@v3
37+
- name: Merge Wheels
38+
uses: actions/upload-artifact/merge@v4
6139
with:
6240
name: wheels
63-
path: ./wheelhouse
41+
pattern: wheels-*
42+
delete-merged: true

.github/workflows/pip_install_gmpy2.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- uses: actions/checkout@v4
15-
- uses: actions/setup-python@v4
15+
- uses: actions/setup-python@v5
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818
allow-prereleases: true
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ${{ matrix.os }}
3232
steps:
3333
- uses: actions/checkout@v4
34-
- uses: actions/setup-python@v4
34+
- uses: actions/setup-python@v5
3535
with:
3636
python-version: ${{ matrix.python-version }}
3737
- name: Install Libs
@@ -70,7 +70,7 @@ jobs:
7070
gcov_include: src/*.c
7171
gcov_args: --no-external
7272
- name: Archive build artifacts
73-
uses: actions/upload-artifact@v3
73+
uses: actions/upload-artifact@v4
7474
if: matrix.python-version == 3.11
7575
with:
7676
path: |
@@ -89,7 +89,7 @@ jobs:
8989
run:
9090
shell: msys2 {0}
9191
steps:
92-
- uses: actions/checkout@v3
92+
- uses: actions/checkout@v4
9393
- uses: msys2/setup-msys2@v2
9494
name: Setup msys2
9595
with:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ['setuptools>=61', 'wheel', 'build']
2+
requires = ['setuptools>=61']
33
build-backend = 'setuptools.build_meta'
44

55
[project]

scripts/before_ci_build.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/before_ci_build_apple_silicon.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/cibw_before_all.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
GMP_VERSION=6.3.0
6+
MPFR_VERSION=4.2.1
7+
MPC_VERSION=1.3.1
8+
9+
PREFIX="$(pwd)/.local/"
10+
11+
# -- build GMP --
12+
curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz
13+
tar -xf gmp-${GMP_VERSION}.tar.xz
14+
cd gmp-${GMP_VERSION}
15+
# config.guess uses microarchitecture and configfsf.guess doesn't
16+
# We replace config.guess with configfsf.guess to avoid microarchitecture
17+
# specific code in common code.
18+
rm config.guess && mv configfsf.guess config.guess && chmod +x config.guess
19+
./configure --enable-fat \
20+
--enable-shared \
21+
--disable-static \
22+
--prefix=$PREFIX
23+
make -j6
24+
make install
25+
cd ../
26+
27+
# -- build MPFR --
28+
curl -s -O https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.gz
29+
tar -xf mpfr-${MPFR_VERSION}.tar.gz
30+
cd mpfr-${MPFR_VERSION}
31+
./configure --enable-shared \
32+
--disable-static \
33+
--with-gmp=$PREFIX \
34+
--prefix=$PREFIX
35+
make -j6
36+
make install
37+
cd ../
38+
# -- build MPC --
39+
curl -s -O https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz
40+
tar -xf mpc-${MPC_VERSION}.tar.gz
41+
cd mpc-${MPC_VERSION}
42+
./configure --enable-shared \
43+
--disable-static \
44+
--with-gmp=$PREFIX \
45+
--with-mpfr=$PREFIX \
46+
--prefix=$PREFIX
47+
make -j6
48+
make install
49+
cd ../
50+
51+
# -- copy headers --
52+
cp $PREFIX/include/{gmp,mpfr,mpc}.h gmpy2/

scripts/cibw_repair_wheel_command.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
DEST_DIR=$1
4+
WHEEL=$2
5+
LD_LIBRARY_PATH="$(pwd)/.local/lib:$LD_LIBRARY_PATH"
6+
7+
if [[ "$OSTYPE" == "darwin"* ]]
8+
then
9+
delocate-wheel --lib-sdir ../gmpy2.libs -w ${DEST_DIR} -v ${WHEEL}
10+
else
11+
auditwheel repair -w ${DEST_DIR} ${WHEEL}
12+
fi

scripts/repair_ci_wheel.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

setup.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
1+
import os
12
import platform
23
from setuptools import setup, Extension
34
from setuptools.command.build_ext import build_ext
4-
import shutil
55
from pathlib import Path
66

77
ON_WINDOWS = platform.system() == 'Windows'
88
_comp_args = ["DSHARED=1"]
99
sources = ['src/gmpy2.c']
10-
winlibs = ['gmp.h','mpfr.h','mpc.h',
11-
'gmp.lib','mpfr.lib','mpc.lib',
12-
'libgmp-10.dll','libmpfr-6.dll','libmpc-3.dll',
13-
'libgcc_s_seh-1.dll','libwinpthread-1.dll']
14-
15-
# Copy the pre-built Windows libraries to the 'gmpy2' directory'.
16-
# If you're not on Windows, delete the Windows libraries from the 'gmpy2'
17-
# directory if the they exist.
18-
src = Path('mingw64') / 'winlibs'
19-
dst = Path('gmpy2')
20-
if ON_WINDOWS:
21-
for filename in winlibs:
22-
try:
23-
shutil.copy(src / filename, dst / filename)
24-
except(FileNotFoundError):
25-
pass
26-
# Also copy gmpy2.h and gmpy2.pxd to gmpy2 directory to avoid symlink
27-
# issues on Windows.
28-
for filename in ['gmpy2.h', 'gmpy2.pxd']:
29-
try:
30-
shutil.copy(Path('src') / filename, dst / filename)
31-
except(FileNotFoundError):
32-
pass
10+
if os.getenv('CIBUILDWHEEL'):
11+
include_dirs = [os.path.join(os.path.dirname(__file__), '.local', 'include')]
12+
library_dirs = [os.path.join(os.path.dirname(__file__), '.local',
13+
'bin' if ON_WINDOWS else 'lib')]
3314
else:
34-
for filename in winlibs:
35-
try:
36-
(dst / filename).unlink()
37-
except(FileNotFoundError):
38-
pass
15+
include_dirs = []
16+
library_dirs = []
3917

4018
class Gmpy2Build(build_ext):
4119
description = "Build gmpy2 with custom build options"
@@ -95,9 +73,9 @@ def build_extensions(self):
9573
extensions = [
9674
Extension('gmpy2.gmpy2',
9775
sources=sources,
98-
include_dirs=['./src'] + (['./gmpy2'] if ON_WINDOWS else []),
99-
libraries=['mpc','mpfr','gmp'] if ON_WINDOWS else ['mpc','mpfr','gmp','m'],
100-
library_dirs=(['./gmpy2'] if ON_WINDOWS else []),
76+
include_dirs=include_dirs,
77+
libraries=['mpc','mpfr','gmp'],
78+
library_dirs=library_dirs,
10179
extra_compile_args=_comp_args,
10280
)
10381
]

0 commit comments

Comments
 (0)