diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b46818df..1100aae5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1748d2c6..2aabcc26 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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 @@ -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: diff --git a/setup.py b/setup.py index bd7fd993..c2e1dc29 100644 --- a/setup.py +++ b/setup.py @@ -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) @@ -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, @@ -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() ) diff --git a/src/_ext.cpp b/src/_ext.cpp index 12c22e42..a7403a4d 100644 --- a/src/_ext.cpp +++ b/src/_ext.cpp @@ -1901,7 +1901,7 @@ PYBIND11_MODULE(_ext, m) { auto off = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor::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++; @@ -2016,7 +2016,7 @@ PYBIND11_MODULE(_ext, m) { auto off = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor::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++;