Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add CXXFLAGS and LDFLAGS handling for aarch64 macOS #317

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
runs-on: [ubuntu-latest, macos-13]
runs-on: [ubuntu-latest, macos-13, macos-latest]
arch: [auto64]
steps:
- uses: actions/checkout@v4
Expand All @@ -48,16 +48,14 @@ jobs:
- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: |
brew install make automake swig gmp mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
brew install make automake swig gmp mpfr boost libtool

- name: Install extra deps on Linux
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig autoconf libtool

- name: Install package
run: |
echo $PATH
python -m pip install '.[test]' -v

- name: Test package
Expand All @@ -69,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13]
os: [ubuntu-latest, macos-13, macos-latest]
python: [312]
arch: [auto64]

Expand All @@ -86,8 +84,7 @@ jobs:
- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: |
brew install make automake swig mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
brew install make automake swig mpfr boost libtool

- name: Clone gmp
if: runner.os == 'macOS'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fail-fast: false
matrix:
python: [38, 39, 310, 311, 312]
os: [ubuntu-latest, macos-13]
os: [ubuntu-latest, macos-13, macos-14]
arch: [auto64]
include:
- python: 38
Expand Down Expand Up @@ -62,8 +62,7 @@ jobs:
- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: |
brew install make automake swig mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
brew install make automake swig mpfr boost libtool

- name: Clone gmp
if: runner.os == 'macOS'
Expand Down
17 changes: 6 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def build_extensions(self):
env = os.environ.copy()
env["PYTHON"] = sys.executable
env["PYTHON_INCLUDE"] = f'-I{sysconfig.get_path("include")}'
env["CXXFLAGS"] = "-O3 -Bstatic -lgmp -Bdynamic -std=c++17"
env["CXX"] = env.get("CXX", "g++")
env["CXXFLAGS"] = "-O3 -Bstatic -Bdynamic -std=c++17 " + env.get(
"CXXFLAGS", ""
)
env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}"
env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN'

Expand Down Expand Up @@ -109,10 +112,6 @@ def build_extensions(self):
subprocess.run(["cat", "config.log"], cwd=FASTJET, check=True)
raise

env = os.environ.copy()
env["CXX"] = env.get("CXX", "g++")
env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}"
env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN'
subprocess.run(["make", "-j"], cwd=FASTJET, env=env, check=True)
subprocess.run(["make", "install"], cwd=FASTJET, env=env, check=True)

Expand All @@ -121,8 +120,7 @@ def build_extensions(self):
"./configure",
f"--fastjet-config={FASTJET}/fastjet-config",
f'CXX={env["CXX"]}',
"CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17",
f'LDFLAGS={env["LDFLAGS"]}',
f'CXXFLAGS={env["CXXFLAGS"]}',
],
cwd=FASTJET_CONTRIB,
env=env,
Expand Down Expand Up @@ -151,10 +149,7 @@ def run(self):

shutil.copytree(OUTPUT, fastjetdir / "_fastjet_core", symlinks=True)

make = "make"
if sys.platform == "darwin":
make = "gmake"

make = "gmake" if sys.platform == "darwin" else "make"
pythondir = pathlib.Path(
subprocess.check_output(
f"""{make} -f Makefile --eval='print-pythondir:
Expand Down
Loading