Skip to content

Commit 2ce8f8a

Browse files
committed
macos wheels
1 parent 0997f7e commit 2ce8f8a

File tree

3 files changed

+62
-16
lines changed

3 files changed

+62
-16
lines changed

.github/workflows/wheels.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,26 @@ jobs:
2828
runs-on: ${{ matrix.os }}
2929
strategy:
3030
matrix:
31-
os: [ ubuntu-24.04 ]
31+
os: [ ubuntu-24.04, macos-13, macos-14 ]
3232
steps:
3333
- name: Checkout
3434
uses: actions/checkout@v4
3535
- name: Setup
3636
run: |
3737
git submodule update --init --recursive
3838
cd eigen && git apply ../patch_size.patch && cd ..
39-
- name: CI Build Wheel
39+
- name: CI Build Wheel macos-14
40+
if: matrix.os == 'macos-14'
41+
uses: pypa/[email protected]
42+
env:
43+
MACOSX_DEPLOYMENT_TARGET: 14.0
44+
- name: CI Build Wheel macos-13
45+
if: matrix.os == 'macos-13'
46+
uses: pypa/[email protected]
47+
env:
48+
MACOSX_DEPLOYMENT_TARGET: 13.0
49+
- name: CI Build Wheel linux
50+
if: matrix.os == 'ubuntu-24.04'
4051
uses: pypa/[email protected]
4152
- name: Upload
4253
uses: actions/upload-artifact@v4

pyproject.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ dependencies = [
4242

4343
[tool.cibuildwheel]
4444
archs = ["auto64"]
45-
skip = [
46-
"*pp*",
47-
]
45+
skip = ["*pp*"]
4846

4947
[[tool.cibuildwheel.overrides]]
5048
select = "*macosx*"
@@ -56,4 +54,4 @@ before-all = "yum install -y gcc-c++ tbb-devel mpfr-devel gmp-devel"
5654

5755
[[tool.cibuildwheel.overrides]]
5856
select = "*musllinux*"
59-
before-all = "apk add gcc-c++ onetbb-dev mpfr-dev gmp-dev"
57+
before-all = "apk add g++ onetbb-dev mpfr-dev gmp-dev"

setup.py

+47-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,55 @@
1+
import os
12
import platform
23
from datetime import datetime
34
from pathlib import Path
45

56
from pybind11.setup_helpers import Pybind11Extension, build_ext
67
from setuptools import setup
78

9+
if "Darwin" == platform.system():
10+
os.environ["CC"] = "gcc-13"
11+
os.environ["CXX"] = "g++-13"
12+
13+
include_dirs = [
14+
"eigen",
15+
"eigen/unsupported",
16+
"mpreal",
17+
"exprtk",
18+
"exprtk-custom-types",
19+
]
20+
21+
library_dirs = []
22+
23+
24+
def add_to_include(target: str):
25+
if not os.path.exists(target):
26+
return
27+
28+
for root, dirs, _ in os.walk(target):
29+
if "include" in dirs:
30+
include_dirs.append(root + "/include")
31+
break
32+
33+
34+
def add_to_library(target: str, header: str):
35+
if not os.path.exists(target):
36+
return
37+
38+
for root, _, files in os.walk(target):
39+
if any(header in file for file in files):
40+
library_dirs.append(root)
41+
break
42+
43+
44+
for root in ["/opt/homebrew/Cellar", "/usr/local/Cellar"]:
45+
add_to_include(f"{root}/mpfr")
46+
add_to_include(f"{root}/gmp")
47+
add_to_include(f"{root}/tbb")
48+
49+
add_to_library(f"{root}/mpfr", "libmpfr")
50+
add_to_library(f"{root}/gmp", "libgmp")
51+
add_to_library(f"{root}/tbb", "libtbb")
52+
853
# noinspection PyTypeChecker
954
setup(
1055
version=datetime.now().strftime("%y%m%d"),
@@ -18,18 +63,10 @@
1863
Pybind11Extension(
1964
"_pyvpmr",
2065
["src/VPMR.cpp"],
21-
include_dirs=[
22-
"eigen",
23-
"eigen/unsupported",
24-
"mpreal",
25-
"exprtk",
26-
"exprtk-custom-types",
27-
],
66+
include_dirs=include_dirs,
67+
library_dirs=library_dirs,
2868
libraries=["mpfr", "gmp", "tbb"],
2969
define_macros=[("PYVPMR", 1)],
30-
extra_compile_args=["-fno-aligned-allocation"]
31-
if "Darwin" == platform.system()
32-
else [],
3370
),
3471
],
3572
cmdclass={"build_ext": build_ext},

0 commit comments

Comments
 (0)