From cd3c71ebd22e99b93ce71e106b7ca6ff05299340 Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Wed, 26 Jun 2024 14:06:42 +0200 Subject: [PATCH 01/12] Fix CMake configuration to work on macOS Explicitly set the C++ standard to C++11 for clang's benefit. This is copied from the corresponding CMakeLists in the main casacore repo. It also disables GCC extensions to make clang extra happy. The Darwin linker (ld) doesn't have the `--as-needed` option. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 313cc22..21d99d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.15...3.26) project(python-casacore) +# Require a C++11 compatible compiler with no funny stuff +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + find_package( Python COMPONENTS Interpreter Development.Module From b7831559325cfe46b4fd7b759461d149c01d0732 Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Fri, 28 Jun 2024 16:22:06 +0200 Subject: [PATCH 02/12] Fix macOS action - The macos-11 runner stopped today :-) - The latest casacore Homebrew formula includes Python support by default - Remove Intel-specific compiler flags (unnecessary on my laptop) - Use a more modern name... --- .github/workflows/osx.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index db588cc..cd78cc8 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -1,4 +1,4 @@ -name: OS X +name: macOS on: push: @@ -9,7 +9,7 @@ on: jobs: osx: - runs-on: macos-11 + runs-on: [macos-13, macos-14] continue-on-error: true steps: @@ -22,7 +22,7 @@ jobs: - name: install homebrew packages run: | brew tap casacore/tap - brew install casacore --with-python + brew install casacore - name: make virtualenv run: python3 -m venv venv @@ -31,7 +31,7 @@ jobs: run: venv/bin/pip install --upgrade pip wheel delocate pytest - name: Compile and install python-casacore - run: CFLAGS="-I/usr/local/include -L/usr/local/lib" venv/bin/pip install . + run: venv/bin/pip install . - name: Run pytest run: venv/bin/pytest From 59ca0398650792c9d35aaf775cfcd1be6f3d14ea Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Fri, 28 Jun 2024 16:52:32 +0200 Subject: [PATCH 03/12] Fix brain-dead action I forgot to add the runner versions to a matrix. Also fix the test invocation. --- .github/workflows/osx.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index cd78cc8..d4a0169 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -1,4 +1,4 @@ -name: macOS +name: Build macOS Homebrew wheels on: push: @@ -8,8 +8,13 @@ on: branches: [ master ] jobs: - osx: - runs-on: [macos-13, macos-14] + build_wheel_macos: + strategy: + fail-fast: false + matrix: + os: [macos-13, macos-14] + runs-on: ${{ matrix.os }} + # This is still pretty much an experimental feature continue-on-error: true steps: @@ -34,7 +39,7 @@ jobs: run: venv/bin/pip install . - name: Run pytest - run: venv/bin/pytest + run: cd tests && venv/bin/pytest - name: make binary wheel run: venv/bin/pip wheel -w dist . From 5b0fa1c7ab4f5a3129d2d7aa13e1fbeb8246b32b Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Fri, 28 Jun 2024 17:50:10 +0200 Subject: [PATCH 04/12] Fix pytest path, since we cd'ed into tests --- .github/workflows/osx.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index d4a0169..a4d8956 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -39,7 +39,7 @@ jobs: run: venv/bin/pip install . - name: Run pytest - run: cd tests && venv/bin/pytest + run: cd tests && ../venv/bin/pytest - name: make binary wheel run: venv/bin/pip wheel -w dist . @@ -47,7 +47,7 @@ jobs: - name: Delocate binary wheel run: venv/bin/delocate-wheel -v dist/*.whl - - name: Publish OS X binary wheels + - name: Publish macOS binary wheels uses: actions/upload-artifact@v4 with: path: dist/*.whl From 33d755b08d87ffe7042edc413f1ec21e92f8359b Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Fri, 28 Jun 2024 18:19:43 +0200 Subject: [PATCH 05/12] Use the system numpy in GitHub action Casacore will be compiled against Homebrew numpy 1.26.4, while the virtual environment will cause python-casacore to pull in numpy 2.0.0 from PyPI. Those two won't play well together. Reconsider when Homebrew ships with numpy 2.0.0. Even then, it doesn't seem like a great idea to compile against one instance of numpy and run against another. --- .github/workflows/osx.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index a4d8956..611eed1 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -30,7 +30,9 @@ jobs: brew install casacore - name: make virtualenv - run: python3 -m venv venv + # XXX Use Homebrew's numpy to be safe for now, especially since + # PyPI is now on numpy 2.0, which complicates matters + run: python3 -m venv venv --system-site-packages - name: Install Python dependencies run: venv/bin/pip install --upgrade pip wheel delocate pytest From ff1295632fd158f472b9cc460e4f7c2a4884f8b5 Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 16:39:53 +0200 Subject: [PATCH 06/12] Enforce Homebrew Python on Intel macOS runners It appears that GitHub runners come with an extra "framework" Python symlinked into /usr/local. On arm64 runners this has no effect, since the Homebrew prefix has changed to /opt/homebrew. On x86_64 runners, however, Homebrew still lives in /usr/local and this is probably why CMake can't find the right Python. Try the minimum workaround first. --- .github/workflows/osx.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 611eed1..fc78485 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -18,18 +18,22 @@ jobs: continue-on-error: true steps: - - name: checkout + - name: Checkout uses: actions/checkout@v4 with: # Needed for `setuptools-scm` fetch-depth: 0 - - name: install homebrew packages + # See https://github.com/orgs/Homebrew/discussions/3895#discussioncomment-4130560 + - name: Ensure we use Homebrew Python + run: find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + + - name: Install Homebrew packages run: | brew tap casacore/tap brew install casacore - - name: make virtualenv + - name: Make virtualenv # XXX Use Homebrew's numpy to be safe for now, especially since # PyPI is now on numpy 2.0, which complicates matters run: python3 -m venv venv --system-site-packages @@ -43,7 +47,7 @@ jobs: - name: Run pytest run: cd tests && ../venv/bin/pytest - - name: make binary wheel + - name: Make binary wheel run: venv/bin/pip wheel -w dist . - name: Delocate binary wheel From c611da0c8d1cea4d6cf03cd41b90e39733ba597f Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 17:02:59 +0200 Subject: [PATCH 07/12] Fix Homebrew Python on Intel runner (take 2) It looks like the virtualenv did not honour --system-site-packages so add some more steps to the Python fix. --- .github/workflows/osx.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index fc78485..c72cbaa 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -26,7 +26,9 @@ jobs: # See https://github.com/orgs/Homebrew/discussions/3895#discussioncomment-4130560 - name: Ensure we use Homebrew Python - run: find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + run: | + find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + brew update - name: Install Homebrew packages run: | From 945fc1e938e6dff0a5e67ce7d12a5f3eac856a5b Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 17:50:12 +0200 Subject: [PATCH 08/12] Restore Homebrew Python on Intel macOS runners Another poke in the dark, inspired by Rodrigo's casacore/casacore#1328. --- .github/workflows/osx.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index c72cbaa..118345c 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -28,7 +28,8 @@ jobs: - name: Ensure we use Homebrew Python run: | find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete - brew update + brew unlink python@3.12 + brew link python@3.12 - name: Install Homebrew packages run: | From db201ed5c14a195bee4bbd197473d4c139fa097b Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 21:02:39 +0200 Subject: [PATCH 09/12] Pick a unique artifact filename per runner This avoids a clash upon upload. Also remove the isolated build environment when building the wheel, to ensure that we use Homebrew NumPy < 2.0 (and the one that is linked to casacore). --- .github/workflows/osx.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 118345c..236ce25 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -42,7 +42,7 @@ jobs: run: python3 -m venv venv --system-site-packages - name: Install Python dependencies - run: venv/bin/pip install --upgrade pip wheel delocate pytest + run: venv/bin/pip install --upgrade pip six wheel delocate pytest - name: Compile and install python-casacore run: venv/bin/pip install . @@ -51,7 +51,9 @@ jobs: run: cd tests && ../venv/bin/pytest - name: Make binary wheel - run: venv/bin/pip wheel -w dist . + # XXX Use Homebrew's numpy to be safe for now, especially since + # PyPI is now on numpy 2.0, which complicates matters + run: venv/bin/pip wheel -w dist --no-build-isolation . - name: Delocate binary wheel run: venv/bin/delocate-wheel -v dist/*.whl @@ -59,4 +61,5 @@ jobs: - name: Publish macOS binary wheels uses: actions/upload-artifact@v4 with: + name: wheel_${{ matrix.os }} path: dist/*.whl From 9679be27d96f82e2d8800e2f8fd866ae43f231f7 Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 21:20:54 +0200 Subject: [PATCH 10/12] Add missing build dependency due to no isolation --- .github/workflows/osx.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 236ce25..5d26762 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -42,7 +42,7 @@ jobs: run: python3 -m venv venv --system-site-packages - name: Install Python dependencies - run: venv/bin/pip install --upgrade pip six wheel delocate pytest + run: venv/bin/pip install --upgrade pip wheel delocate pytest - name: Compile and install python-casacore run: venv/bin/pip install . @@ -53,7 +53,9 @@ jobs: - name: Make binary wheel # XXX Use Homebrew's numpy to be safe for now, especially since # PyPI is now on numpy 2.0, which complicates matters - run: venv/bin/pip wheel -w dist --no-build-isolation . + run: | + venv/bin/pip install --upgrade six scikit-build-core + venv/bin/pip wheel -w dist --no-build-isolation . - name: Delocate binary wheel run: venv/bin/delocate-wheel -v dist/*.whl From 5d23a26f6df0b568d2c8c3f22182e385c5970cd3 Mon Sep 17 00:00:00 2001 From: Ludwig Schwardt Date: Mon, 1 Jul 2024 22:45:44 +0200 Subject: [PATCH 11/12] Add missing dependency to wheel build environment --- .github/workflows/osx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 5d26762..dfd7c60 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -54,7 +54,7 @@ jobs: # XXX Use Homebrew's numpy to be safe for now, especially since # PyPI is now on numpy 2.0, which complicates matters run: | - venv/bin/pip install --upgrade six scikit-build-core + venv/bin/pip install --upgrade six scikit-build-core setuptools_scm venv/bin/pip wheel -w dist --no-build-isolation . - name: Delocate binary wheel From b8cf533bf03c1c2fbde11c5315730c4d29b3e46e Mon Sep 17 00:00:00 2001 From: Tammo Jan Dijkema Date: Thu, 29 Aug 2024 20:41:41 +0200 Subject: [PATCH 12/12] Remove numpy 2.0 workarounds --- .github/workflows/osx.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index dfd7c60..4948f93 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -37,9 +37,7 @@ jobs: brew install casacore - name: Make virtualenv - # XXX Use Homebrew's numpy to be safe for now, especially since - # PyPI is now on numpy 2.0, which complicates matters - run: python3 -m venv venv --system-site-packages + run: python3 -m venv venv - name: Install Python dependencies run: venv/bin/pip install --upgrade pip wheel delocate pytest @@ -51,11 +49,9 @@ jobs: run: cd tests && ../venv/bin/pytest - name: Make binary wheel - # XXX Use Homebrew's numpy to be safe for now, especially since - # PyPI is now on numpy 2.0, which complicates matters run: | venv/bin/pip install --upgrade six scikit-build-core setuptools_scm - venv/bin/pip wheel -w dist --no-build-isolation . + venv/bin/pip wheel -w dist . - name: Delocate binary wheel run: venv/bin/delocate-wheel -v dist/*.whl