Skip to content
Open
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ include *.py
include *.release
include *.sh
include LICENSE
include _build/*.py
36 changes: 36 additions & 0 deletions _build/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- 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"
)
log.debug(f"{ncconfig = }")
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 []
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ requires = [
"Cython>=0.29",
"oldest-supported-numpy ; python_version < '3.9'",
"numpy>=2.0.0rc1 ; python_version >= '3.9'",
"setuptools>=61", "setuptools_scm[toml]>=3.4"
"setuptools>=61",
"setuptools_scm[toml]>=3.4",
"wheel"
]
build-backend = "setuptools.build_meta"
build-backend = "backend"
backend-path = ["_build"]

[project]
name = "netCDF4"
Expand Down