From 1a96ee97550fb60d1e8685d9cf2ad10e5ab241d6 Mon Sep 17 00:00:00 2001 From: stubbiali Date: Thu, 31 Aug 2023 00:05:01 +0200 Subject: [PATCH 1/8] Update build requirements. --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 01562cefb..3e3376605 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,9 @@ [build-system] requires = [ - "Cython>=0.29", + "Cython==0.29.36", + "mpi4py>=3.1", "oldest-supported-numpy", - "setuptools>=61", + "setuptools>=65.5.0", ] build-backend = "setuptools.build_meta" From de11aa698494fb0cbaef1f10f2fc31aa518cdbb1 Mon Sep 17 00:00:00 2001 From: stubbiali Date: Thu, 31 Aug 2023 10:36:40 +0200 Subject: [PATCH 2/8] Relax constraint on cython. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3e3376605..8b2bd8629 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "Cython==0.29.36", + "Cython>=0.29", "mpi4py>=3.1", "oldest-supported-numpy", "setuptools>=65.5.0", From 60d27910d728a3d796db9b9e0e27e0b81409f6b0 Mon Sep 17 00:00:00 2001 From: stubbiali Date: Tue, 9 Jan 2024 10:31:08 +0100 Subject: [PATCH 3/8] Relax constraint on setuptools. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ba1807a9f..cb3d98717 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [build-system] requires = [ "Cython>=0.29", - "mpi4py>=3.1", + "mpi4py>=3.1", "oldest-supported-numpy", - "setuptools>=65.5.0", + "setuptools>=61", ] build-backend = "setuptools.build_meta" From 0744c89bb06489b17f1ed190eb26eed435268da9 Mon Sep 17 00:00:00 2001 From: stubbiali Date: Tue, 9 Jan 2024 15:11:50 +0100 Subject: [PATCH 4/8] Add in-tree build backend. --- MANIFEST.in | 1 + _build/backend.py | 25 +++++++++++++++++++++++++ pyproject.toml | 5 +++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 _build/backend.py diff --git a/MANIFEST.in b/MANIFEST.in index e3497466e..545dec44b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -22,3 +22,4 @@ include *.py include *.release include *.sh include LICENSE +include _build/*.py diff --git a/_build/backend.py b/_build/backend.py new file mode 100644 index 000000000..cefffa925 --- /dev/null +++ b/_build/backend.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import os +from setuptools.build_meta import * +import subprocess + + +def netcdf_has_parallel_support(): + netcdf4_dir = os.environ.get("NETCDF4_DIR") + ncconfig = os.path.join(netcdf4_dir, "bin", "nc-config") if netcdf4_dir else "nc-config" + process = subprocess.run([ncconfig, "--has-parallel4"], capture_output=True) + out = process.stdout.decode("utf-8").rstrip() + return out == "yes" + + +def get_requires_for_build_editable(config_settings=None): + return ["mpi4py>=3.1"] if netcdf_has_parallel_support() else [] + + +def get_requires_for_build_wheel(config_settings=None): + return ["mpi4py>=3.1"] if netcdf_has_parallel_support() else [] + + +def get_requires_for_build_sdist(config_settings=None): + return ["mpi4py>=3.1"] if netcdf_has_parallel_support() else [] + diff --git a/pyproject.toml b/pyproject.toml index cb3d98717..f0467a670 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,12 @@ [build-system] requires = [ "Cython>=0.29", - "mpi4py>=3.1", "oldest-supported-numpy", "setuptools>=61", + "wheel" ] -build-backend = "setuptools.build_meta" +build-backend = "backend" +backend-path = ["_build"] [project] name = "netCDF4" From 64faa9b968121b88d14051c3212ac8076f720049 Mon Sep 17 00:00:00 2001 From: stubbiali Date: Fri, 16 Feb 2024 22:07:52 +0100 Subject: [PATCH 5/8] Debug CI. --- _build/backend.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/_build/backend.py b/_build/backend.py index cefffa925..bd05c2b3e 100644 --- a/_build/backend.py +++ b/_build/backend.py @@ -1,12 +1,24 @@ # -*- coding: utf-8 -*- +import logging import os from setuptools.build_meta import * import subprocess +fmt = logging.Formatter("\n=== NETCDF4 BUILD DEBUG: %(message)s\n") +hdlr = logging.StreamHandler() +hdlr.setFormatter(fmt) +log = logging.getLogger(__name__) +log.setLevel(logging.DEBUG) +log.addHandler(hdlr) + + def netcdf_has_parallel_support(): netcdf4_dir = os.environ.get("NETCDF4_DIR") - ncconfig = os.path.join(netcdf4_dir, "bin", "nc-config") if netcdf4_dir else "nc-config" + ncconfig = ( + os.path.join(netcdf4_dir, "bin", "nc-config") if netcdf4_dir else "nc-config" + ) + log.debug(f"{ncconfig = }") process = subprocess.run([ncconfig, "--has-parallel4"], capture_output=True) out = process.stdout.decode("utf-8").rstrip() return out == "yes" @@ -22,4 +34,3 @@ def get_requires_for_build_wheel(config_settings=None): def get_requires_for_build_sdist(config_settings=None): return ["mpi4py>=3.1"] if netcdf_has_parallel_support() else [] - From d2b05c5741ef33773ac40ffc4d0ccc89d5bd8f29 Mon Sep 17 00:00:00 2001 From: jswhit2 Date: Tue, 28 Oct 2025 14:07:22 -0600 Subject: [PATCH 6/8] add $CONDA_PREFIX/bin to PATH on windows --- .github/workflows/cibuildwheel.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 2a2ebf717..516e114ac 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -129,6 +129,7 @@ jobs: uses: pypa/cibuildwheel@v3.2.1 env: CIBW_ARCHS: ${{ matrix.arch }} + CIBW_ENVIRONMENT: > PATH="${CONDA_PREFIX}/bin:$PATH" - uses: actions/upload-artifact@v5 with: From 5fb1c221237937fe24c11af733c11959e801c56e Mon Sep 17 00:00:00 2001 From: jswhit2 Date: Tue, 28 Oct 2025 14:19:23 -0600 Subject: [PATCH 7/8] add CONDA_PREFIX to path in pyproject.toml for cibuildwheel --- .github/workflows/cibuildwheel.yml | 1 - pyproject.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 516e114ac..2a2ebf717 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -129,7 +129,6 @@ jobs: uses: pypa/cibuildwheel@v3.2.1 env: CIBW_ARCHS: ${{ matrix.arch }} - CIBW_ENVIRONMENT: > PATH="${CONDA_PREFIX}/bin:$PATH" - uses: actions/upload-artifact@v5 with: diff --git a/pyproject.toml b/pyproject.toml index 73cf86580..61ea02647 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,6 +140,7 @@ environment = {MACOSX_DEPLOYMENT_TARGET="14.0"} [tool.cibuildwheel.windows] before-build = "python -m pip install delvewheel" +environment = "PATH=$CONDA_PREFIX/bin:$PATH" repair-wheel-command = [ "delvewheel show {wheel}", "delvewheel repair -w {dest_dir} {wheel}", From 7eef3947bd32ade448d01dfeb090d874f204ff05 Mon Sep 17 00:00:00 2001 From: jswhit2 Date: Tue, 28 Oct 2025 16:48:14 -0600 Subject: [PATCH 8/8] update --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61ea02647..2605ce84c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,7 +140,7 @@ environment = {MACOSX_DEPLOYMENT_TARGET="14.0"} [tool.cibuildwheel.windows] before-build = "python -m pip install delvewheel" -environment = "PATH=$CONDA_PREFIX/bin:$PATH" +environment = "PATH=$PATH:$CONDA_PREFIX/bin" repair-wheel-command = [ "delvewheel show {wheel}", "delvewheel repair -w {dest_dir} {wheel}",