Skip to content

Commit

Permalink
Add in-tree build backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
stubbiali committed Jan 9, 2024
1 parent 60d2791 commit 0744c89
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ include *.py
include *.release
include *.sh
include LICENSE
include _build/*.py
25 changes: 25 additions & 0 deletions _build/backend.py
Original file line number Diff line number Diff line change
@@ -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 []

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 0744c89

Please sign in to comment.