Skip to content

Commit 77d3fc0

Browse files
committed
BLD: avoid a deprecation warning from setuptools (PEP 735 license metadata)
1 parent b693757 commit 77d3fc0

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ include *.md
2727
include *.py
2828
include *.release
2929
include *.sh
30-
include LICENSE

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ requires = [
33
"Cython>=0.29",
44
"oldest-supported-numpy ; python_version < '3.9'",
55
"numpy>=2.0.0rc1 ; python_version >= '3.9'",
6-
"setuptools>=61", "setuptools_scm[toml]>=3.4"
6+
"setuptools>=77.0.1",
7+
"setuptools_scm[toml]>=3.4",
78
]
89
build-backend = "setuptools.build_meta"
910

@@ -18,7 +19,8 @@ keywords = [
1819
"numpy", "netcdf", "data", "science", "network", "oceanography",
1920
"meteorology", "climate",
2021
]
21-
license = {text = "MIT"}
22+
license = "MIT"
23+
license-files = ["LICENSE"]
2224
classifiers = [
2325
"Development Status :: 3 - Alpha",
2426
"Programming Language :: Python :: 3",
@@ -28,7 +30,6 @@ classifiers = [
2830
"Programming Language :: Python :: 3.12",
2931
"Programming Language :: Python :: 3.13",
3032
"Intended Audience :: Science/Research",
31-
"License :: OSI Approved :: MIT License",
3233
"Topic :: Software Development :: Libraries :: Python Modules",
3334
"Topic :: System :: Archiving :: Compression",
3435
"Operating System :: OS Independent",

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@
33
import pathlib
44
import shutil
55
import configparser
6+
import sysconfig
67
from setuptools import setup, Extension
78
from setuptools.dist import Distribution
89
from typing import List
910

1011

12+
USE_PY_LIMITED_API = (
13+
# require opt-in (builds are specilized by default)
14+
os.getenv('NETCDF4_LIMITED_API', '0') == '1'
15+
# Cython + numpy + limited API de facto requires Python >=3.11
16+
and sys.version_info >= (3, 11)
17+
# as of Python 3.14t, free-threaded builds don't support the limited API
18+
and not sysconfig.get_config_var("Py_GIL_DISABLED")
19+
)
20+
ABI3_TARGET_VERSION = "".join(str(_) for _ in sys.version_info[:2])
21+
ABI3_TARGET_HEX = hex(sys.hexversion & 0xFFFF00F0)
22+
23+
if USE_PY_LIMITED_API:
24+
SETUP_OPTIONS = {"bdist_wheel": {"py_limited_api", f"cp{ABI3_TARGET_VERSION}"}}
25+
else:
26+
SETUP_OPTIONS = {}
1127

1228
open_kwargs = {'encoding': 'utf-8'}
1329

@@ -436,6 +452,8 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
436452
str(nc_complex_dir / "include/generated_fallbacks"),
437453
]
438454
DEFINE_MACROS += [("NC_COMPLEX_NO_EXPORT", "1")]
455+
if USE_PY_LIMITED_API:
456+
DEFINE_MACROS.append(("Py_LIMITED_API", ABI3_TARGET_HEX))
439457

440458
ext_modules = [Extension("netCDF4._netCDF4",
441459
source_files,
@@ -477,6 +495,7 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
477495
name="netCDF4", # need by GitHub dependency graph
478496
version=extract_version(netcdf4_src_pyx),
479497
ext_modules=ext_modules,
498+
options=SETUP_OPTIONS,
480499
)
481500

482501
# remove plugin files copied from outside source tree

0 commit comments

Comments
 (0)