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

does macos building work? #134

Merged
merged 19 commits into from
Dec 16, 2022
Merged
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
24 changes: 19 additions & 5 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.7", "3.11"]
runs-on: [ubuntu-latest] # , macos-latest
runs-on: [ubuntu-latest, macos-latest]

# include:
# - python-version: pypy-3.8
Expand All @@ -51,27 +51,41 @@ jobs:

- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: brew install automake swig gmp mpfr boost
run: |
brew install make gcc automake swig gmp mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

- 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: python -m pip install '.[test]' -v
run: |
echo $PATH
python -m pip install '.[test]' -v

- name: Test package
run: python -m pytest -vv -rs -Wd

test_wheels:
name: Wheel on Linux
runs-on: ubuntu-latest
name: "Wheel on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: |
brew install make gcc automake swig gmp mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

- uses: pypa/cibuildwheel@v2.11.3
env:
CIBW_ARCHS: auto64
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
matrix:
python-build-version:
["cp37-*", "cp38-*", "cp39-*", "cp310-*", "cp311-*"]
os: [ubuntu-latest] # , macos-latest
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
Expand All @@ -39,7 +39,9 @@ jobs:

- name: Install compiler tools on macOS
if: runner.os == 'macOS'
run: brew install automake
run: |
brew install make gcc automake swig gmp mpfr boost
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

- uses: pypa/cibuildwheel@v2.11.3
env:
Expand Down
28 changes: 20 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,27 @@ 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"
env["CXXFLAGS"] = "-O3 -Bstatic -lgmp -Bdynamic -std=c++17"
env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN'

args = [
f"--prefix={OUTPUT}",
"--disable-auto-ptr",
"--enable-allcxxplugins",
"--enable-cgal-header-only",
"--enable-cgal",
f"--with-cgaldir={cgal_dir}",
"--enable-swig",
"--enable-pyext",
"LDFLAGS=-Wl,-rpath=$$ORIGIN/_fastjet_core/lib:$$ORIGIN",
"LDFLAGS=-Wl,-rpath,$$ORIGIN/_fastjet_core/lib:$$ORIGIN",
]

try:
subprocess.run(
["./autogen.sh"] + args, cwd=FASTJET, env=env, check=True
["./autogen.sh"] + args,
cwd=FASTJET,
env=env,
check=True,
)
except Exception:
subprocess.run(["cat", "config.log"], cwd=FASTJET, check=True)
Expand All @@ -106,7 +110,11 @@ def build_extensions(self):
subprocess.run(["make", "install"], cwd=FASTJET, env=env, check=True)

subprocess.run(
["./configure", f"--fastjet-config={FASTJET}/fastjet-config"],
[
"./configure",
f"--fastjet-config={FASTJET}/fastjet-config",
"CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17",
],
cwd=FASTJET_CONTRIB,
env=env,
check=True,
Expand Down Expand Up @@ -134,24 +142,28 @@ def run(self):

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

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

pythondir = pathlib.Path(
subprocess.check_output(
"""make -f pyinterface/Makefile --eval='print-pythondir:
f"""{make} -f Makefile --eval='print-pythondir:
\t@echo $(pythondir)
' print-pythondir""",
shell=True,
cwd=FASTJET,
cwd=FASTJET / "pyinterface",
universal_newlines=True,
).strip()
)

pyexecdir = pathlib.Path(
subprocess.check_output(
"""make -f pyinterface/Makefile --eval='print-pyexecdir:
f"""{make} -f Makefile --eval='print-pyexecdir:
\t@echo $(pyexecdir)
' print-pyexecdir""",
shell=True,
cwd=FASTJET,
cwd=FASTJET / "pyinterface",
universal_newlines=True,
).strip()
)
Expand Down
4 changes: 2 additions & 2 deletions src/_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ PYBIND11_MODULE(_ext, m) {

auto off = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len+1}, {sizeof(int)}));
auto bufoff = off.request();
int *ptroff = (int *)realloc(bufoff.ptr, (len+1)*sizeof(int)+1);;
int *ptroff = (int *)bufoff.ptr;
size_t idxe = 0;
*ptroff = 0;
ptroff++;
Expand Down Expand Up @@ -2016,7 +2016,7 @@ PYBIND11_MODULE(_ext, m) {

auto off = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len+1}, {sizeof(int)}));
auto bufoff = off.request();
int *ptroff = (int *)realloc(bufoff.ptr, (len+1)*sizeof(int)+1);;
int *ptroff = (int *)bufoff.ptr;
size_t idxe = 0;
*ptroff = 0;
ptroff++;
Expand Down