From 493e80591857558e29862e9ae3a99bb42d720c00 Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Wed, 25 Jun 2025 16:57:02 +1000 Subject: [PATCH 01/10] DEV: Utilise pytest-mock dependency when building wheels --- .github/workflows/build_wheels.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 8a57110..053ba2d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -74,7 +74,7 @@ jobs: CIBW_ARCHS_MACOS: ${{endsWith(matrix.platform_id, 'universal2') && 'universal2' || 'auto'}} CIBW_ARCHS_WINDOWS: ${{endsWith(matrix.platform_id, '_amd64') && 'AMD64' || 'ARM64'}} CIBW_BUILD: "*${{matrix.platform_id}}" - CIBW_TEST_REQUIRES: pytest + CIBW_TEST_REQUIRES: pytest pytest-mock CIBW_TEST_COMMAND: pytest {package}/tests CIBW_TEST_SKIP: "*-macosx_universal2:x86_64" # skip x86 on m1 mac CIBW_SKIP: pp* # Disable building PyPy wheels on all platforms diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 479df8e..c7cec23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: CIBW_ARCHS_MACOS: ${{endsWith(matrix.platform_id, 'universal2') && 'universal2' || 'auto'}} CIBW_ARCHS_WINDOWS: ${{endsWith(matrix.platform_id, '_amd64') && 'AMD64' || 'ARM64'}} CIBW_BUILD: "*${{matrix.platform_id}}" - CIBW_TEST_REQUIRES: pytest + CIBW_TEST_REQUIRES: pytest pytest-mock CIBW_TEST_COMMAND: pytest {package}/tests CIBW_TEST_SKIP: "*-macosx_universal2:x86_64" # skip x86 on m1 mac CIBW_SKIP: pp* # Disable building PyPy wheels on all platforms From 28dd797469f619508d3f72ce74d8d64176d63791 Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 13:32:46 +1000 Subject: [PATCH 02/10] DEV: Pin cibuildwheel to 2.23.3 while 3.0.0 defaults to broken Python 3.13.4 --- .github/workflows/build_wheels.yml | 3 ++- .github/workflows/release.yml | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 053ba2d..23e4568 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -64,11 +64,12 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Build Wheels - uses: pypa/cibuildwheel@v3.0.0 + uses: pypa/cibuildwheel@v2.23.3 env: # Can specify per os - e.g. CIBW_BEFORE_ALL_LINUX, CIBW_BEFORE_ALL_MACOS, CIBW_BEFORE_ALL_WINDOWS CIBW_BEFORE_ALL_LINUX: ./build_tools/before_all_linux.sh CIBW_BEFORE_ALL_MACOS: ./build_tools/before_all_mac.sh CIBW_BEFORE_ALL_WINDOWS: bash ./build_tools/before_all_windows.sh + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64:latest CIBW_ENVIRONMENT_WINDOWS: Boost_INCLUDE_DIR='${{ steps.install-boost.outputs.BOOST_ROOT }}/include' Boost_LIBRARY_DIRS='${{ steps.install-boost.outputs.BOOST_ROOT }}/lib' CIBW_ARCHS_LINUX: ${{endsWith(matrix.platform_id, '_x86_64') && 'x86_64' || 'aarch64'}} CIBW_ARCHS_MACOS: ${{endsWith(matrix.platform_id, 'universal2') && 'universal2' || 'auto'}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7cec23..d73ea16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,7 +64,7 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Build Wheels - uses: pypa/cibuildwheel@v3.0.0 + uses: pypa/cibuildwheel@v2.23.3 env: # Can specify per os - e.g. CIBW_BEFORE_ALL_LINUX, CIBW_BEFORE_ALL_MACOS, CIBW_BEFORE_ALL_WINDOWS CIBW_BEFORE_ALL_LINUX: ./build_tools/before_all_linux.sh CIBW_BEFORE_ALL_MACOS: ./build_tools/before_all_mac.sh diff --git a/pyproject.toml b/pyproject.toml index a346f8b..c2ea943 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ Documentation = "https://piqtree.readthedocs.io" [project.optional-dependencies] dev = [ - "cibuildwheel", + "cibuildwheel==2.23.3", "pybind11", "delvewheel", "scriv", From e8ee9faa95d42143d1f1e6f1323cdbb8415c74fb Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 13:36:22 +1000 Subject: [PATCH 03/10] DEV: cibuildwheel downgrade means specific image no longer required --- .github/workflows/build_wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 23e4568..7df254d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -69,7 +69,6 @@ jobs: CIBW_BEFORE_ALL_LINUX: ./build_tools/before_all_linux.sh CIBW_BEFORE_ALL_MACOS: ./build_tools/before_all_mac.sh CIBW_BEFORE_ALL_WINDOWS: bash ./build_tools/before_all_windows.sh - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64:latest CIBW_ENVIRONMENT_WINDOWS: Boost_INCLUDE_DIR='${{ steps.install-boost.outputs.BOOST_ROOT }}/include' Boost_LIBRARY_DIRS='${{ steps.install-boost.outputs.BOOST_ROOT }}/lib' CIBW_ARCHS_LINUX: ${{endsWith(matrix.platform_id, '_x86_64') && 'x86_64' || 'aarch64'}} CIBW_ARCHS_MACOS: ${{endsWith(matrix.platform_id, 'universal2') && 'universal2' || 'auto'}} From a77c69ff120e58f4d9d5ae9ae1b2c6359dee962c Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 15:34:18 +1000 Subject: [PATCH 04/10] DEV: attempt to reduce linux wheel file size --- setup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a87ad72..d4fab16 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import os import platform import subprocess +import sys from pathlib import Path from pybind11.setup_helpers import Pybind11Extension, build_ext @@ -100,10 +101,25 @@ def setup_linux() -> None: ), ] + +# ⬇️ Custom build_ext to strip .so on Linux +class StripBuildExt(build_ext): + def run(self) -> None: + super().run() + if sys.platform.startswith("linux"): + for ext in self.extensions: + so_path = self.get_ext_fullpath(ext.name) + if Path(so_path).exists(): + subprocess.run( + ["strip", "--strip-unneeded", so_path], + check=True, + ) + + setup( name="piqtree", ext_modules=ext_modules, - cmdclass={"build_ext": build_ext}, + cmdclass={"build_ext": StripBuildExt}, zip_safe=False, package_data={"piqtree": ["_libiqtree/*.dll"]}, ) From 511542fcdb2d521a24bfc2f99c0a3282f14a47d0 Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 15:58:12 +1000 Subject: [PATCH 05/10] DEV: also attempt to strip macos wheels --- setup.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index d4fab16..05e355d 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ import os import platform import subprocess -import sys from pathlib import Path from pybind11.setup_helpers import Pybind11Extension, build_ext @@ -102,18 +101,17 @@ def setup_linux() -> None: ] -# ⬇️ Custom build_ext to strip .so on Linux class StripBuildExt(build_ext): def run(self) -> None: super().run() - if sys.platform.startswith("linux"): + + if platform.system() in ("Darwin", "Linux"): for ext in self.extensions: so_path = self.get_ext_fullpath(ext.name) - if Path(so_path).exists(): - subprocess.run( - ["strip", "--strip-unneeded", so_path], - check=True, - ) + subprocess.run( + ["strip", "--strip-unneeded", so_path], + check=True, + ) setup( From 1bacea5bbcd4a791cf9ae60a195260c9f5d102fe Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 16:07:35 +1000 Subject: [PATCH 06/10] DEV: only strip .so on linux --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05e355d..a6f207a 100644 --- a/setup.py +++ b/setup.py @@ -105,7 +105,7 @@ class StripBuildExt(build_ext): def run(self) -> None: super().run() - if platform.system() in ("Darwin", "Linux"): + if platform.system() in "Linux": for ext in self.extensions: so_path = self.get_ext_fullpath(ext.name) subprocess.run( From 80cd516f5027175c89a4e7cd33c2d32ff1c880a2 Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 16:11:05 +1000 Subject: [PATCH 07/10] DEV: attempt stripping on macos again --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a6f207a..be85502 100644 --- a/setup.py +++ b/setup.py @@ -105,11 +105,12 @@ class StripBuildExt(build_ext): def run(self) -> None: super().run() - if platform.system() in "Linux": + if system := platform.system() in ("Darwin", "Linux"): + flag = "--strip-unneeded" if system == "Linux" else "-x" for ext in self.extensions: so_path = self.get_ext_fullpath(ext.name) subprocess.run( - ["strip", "--strip-unneeded", so_path], + ["strip", flag, so_path], check=True, ) From 3a3c3c24b14eae38fc624fbf78f2692c4b8484da Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 16:33:07 +1000 Subject: [PATCH 08/10] DEV: Strip on all platforms --- setup.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index be85502..c03dd23 100644 --- a/setup.py +++ b/setup.py @@ -105,14 +105,11 @@ class StripBuildExt(build_ext): def run(self) -> None: super().run() - if system := platform.system() in ("Darwin", "Linux"): - flag = "--strip-unneeded" if system == "Linux" else "-x" - for ext in self.extensions: - so_path = self.get_ext_fullpath(ext.name) - subprocess.run( - ["strip", flag, so_path], - check=True, - ) + system = platform.system() + flag = "-x" if system == "Dawin" else "--strip-unneeded" + for ext in self.extensions: + so_path = self.get_ext_fullpath(ext.name) + subprocess.run(["strip", flag, so_path], check=True) setup( From 4ab88a3bf47ca4aa5ba4f56526cb75bfe478fb8b Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 16:47:25 +1000 Subject: [PATCH 09/10] MAINT: fix typo in Darwin --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c03dd23..4cbb58b 100644 --- a/setup.py +++ b/setup.py @@ -106,7 +106,7 @@ def run(self) -> None: super().run() system = platform.system() - flag = "-x" if system == "Dawin" else "--strip-unneeded" + flag = "-x" if system == "Darwin" else "--strip-unneeded" for ext in self.extensions: so_path = self.get_ext_fullpath(ext.name) subprocess.run(["strip", flag, so_path], check=True) From 7f22a3a3e6c82efc36478ceef5d385f0ee355c41 Mon Sep 17 00:00:00 2001 From: Robert McArthur Date: Thu, 26 Jun 2025 17:10:14 +1000 Subject: [PATCH 10/10] MAINT: rename so_path to ext_path --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4cbb58b..aa04533 100644 --- a/setup.py +++ b/setup.py @@ -108,8 +108,8 @@ def run(self) -> None: system = platform.system() flag = "-x" if system == "Darwin" else "--strip-unneeded" for ext in self.extensions: - so_path = self.get_ext_fullpath(ext.name) - subprocess.run(["strip", flag, so_path], check=True) + ext_path = self.get_ext_fullpath(ext.name) + subprocess.run(["strip", flag, ext_path], check=True) setup(