Skip to content

Commit fc2bc17

Browse files
DWeslkafitzgerald
andauthored
BLD: Add pyproject.toml (#241)
* BLD: Initial try at pyproject.toml I think I got every key from setup.py. The main difference is if the READTHEDOCS environment variable is set: I don't know how to change the dependencies based on that. On the other hand, given 3.8 is close to or past EOL, I suspect 3.3 is relatively uncommon, and the RTD install, without the unneeded bits, could be accomplished with pip install --no-deps. * BLD,BUG: Fix pyproject.toml configuration and remove setup.py duplicates. numpy.distutils recommends setuptools<60, but that breaks pyproject.toml configuration. I like this way better. Still needs setup.py for the fortran module and for the Cheyenne configuration. * FIX: Require a setuptools version that understands the configuration. setuptools<60 just gets confused, and has no idea what the project name is. I just inverted that requirement: not sure if setuptools needs to be more recent still. * BLD: Quote version requirement. * BLD: Specify dependencies in pyproject.toml only. Remove requirements.txt. * DOC: Don't install dependencies on RTD The old setup script replaced the dependencies listed in requirements.txt with mock if python was old enough and nothing if python was recent. The package no longer supports python versions that old (<3.3), so installing without dependencies is likely the correct way to handle the RTD configuration. * BLD,BUG: Remove references to requirements, not just definitions Forgot to remove this two or three commits back. * BLD: Let's see if NumPy < 2.0 fixes the error * BLD: Pin setuptools<60 NumPy suggested it, it might help with the distutils failure. * BLD: Pin setuptools<71 Let's see if that change is the one that broke things. * BLD: Add subroutines to f90 modules so f2py adds code for them. If it's just constants used somewhere, f2py drops the module. * BLD: Remove build-time setuptools pin. * BLD: Pin setuptools<70 to get msvccompiler * BLD: Add -fopenmp to LDFLAGS Let's see if this gets Linux compiles working. --------- Co-authored-by: Katelyn FitzGerald <[email protected]>
1 parent 302bd5f commit fc2bc17

File tree

10 files changed

+77
-73
lines changed

10 files changed

+77
-73
lines changed

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build:
1111
python: "mambaforge-4.10"
1212
jobs:
1313
post_create_environment:
14-
- python -m pip install --no-cache-dir .
14+
- python -m pip install --no-cache-dir --no-deps .
1515

1616
# Build documentation in the docs/ directory with Sphinx
1717
sphinx:

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include README.md
22
include LICENSE
3-
include requirements.txt
43

54
include fortran/*.f90
65
include fortran/*.pyf

build_scripts/gnu_omp.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $FC -E ompgen.F90 -fopenmp -cpp -o omp.f90
1111
cd ..
1212

1313
python setup.py clean --all
14+
export LDFLAGS=" -fopenmp "
1415
python setup.py config_fc --f90flags="-mtune=generic -fopenmp" build_ext --libraries="gomp" build
1516
pip install .
1617

fortran/omp.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ MODULE omp_constants
77
INTEGER(KIND=fomp_sched_kind), PARAMETER :: fomp_sched_dynamic = 2
88
INTEGER(KIND=fomp_sched_kind), PARAMETER :: fomp_sched_guided = 3
99
INTEGER(KIND=fomp_sched_kind), PARAMETER :: fomp_sched_auto = 4
10+
contains
11+
subroutine have_omp_constants()
12+
end subroutine have_omp_constants
1013
END MODULE omp_constants
1114

1215

fortran/ompgen.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ MODULE omp_constants
2020
INTEGER(KIND=4), PARAMETER :: fomp_sched_auto = 4
2121
#endif
2222

23+
contains
24+
subroutine have_omp_constants()
25+
end subroutine have_omp_constants
26+
2327
END MODULE omp_constants
2428

2529

fortran/ompgen.F90.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ MODULE omp_constants
2020
INTEGER(KIND=4), PARAMETER :: fomp_sched_auto = 4
2121
#endif
2222

23+
contains
24+
subroutine have_omp_constants()
25+
end subroutine have_omp_constants
26+
2327
END MODULE omp_constants
2428

2529

fortran/wrf_constants.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ MODULE wrf_constants
6969
REAL(KIND=8), PARAMETER :: EXPON = RD*USSALR/G
7070
REAL(KIND=8), PARAMETER :: EXPONI = 1./EXPON
7171

72+
contains
73+
subroutine have_wrf_constants()
74+
end subroutine have_wrf_constants
7275

7376
END MODULE wrf_constants
7477

pyproject.toml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[build-system]
2+
requires = ["setuptools>=61, <70", "numpy"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "wrf-python"
7+
authors = [
8+
{ name = "Bill Ladwig" }
9+
]
10+
maintainers = [
11+
{ name = "GeoCAT", email = "[email protected]" },
12+
]
13+
description = "Diagnostic and interpolation routines for WRF-ARW data."
14+
readme = "README.md"
15+
requires-python = ">=3.7, <3.12"
16+
keywords = [
17+
"python", "wrf-python", "wrf", "forecast", "model",
18+
"weather research and forecasting", "interpolation",
19+
"plotting", "plots", "meteorology", "nwp",
20+
"numerical weather prediction", "diagnostic",
21+
"science", "numpy"
22+
]
23+
classifiers = [
24+
"Development Status :: 5 - Production/Stable",
25+
"Intended Audience :: Science/Research",
26+
"Intended Audience :: Developers",
27+
"License :: OSI Approved :: Apache Software License",
28+
"Programming Language :: Fortran",
29+
"Programming Language :: Python :: 3.9",
30+
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Topic :: Scientific/Engineering :: Atmospheric Science",
33+
"Topic :: Software Development",
34+
"Operating System :: POSIX",
35+
"Operating System :: Unix",
36+
"Operating System :: MacOS",
37+
"Operating System :: Microsoft :: Windows"
38+
]
39+
license = { text = "Apache-2.0" }
40+
dynamic = [ "version" ]
41+
dependencies = [
42+
"basemap",
43+
"numpy >=1.11, !=1.24.3",
44+
"setuptools",
45+
"wrapt",
46+
"xarray"
47+
]
48+
49+
[project.urls]
50+
Repository = "https://github.com/NCAR/wrf-python"
51+
Documentation = "https://wrf-python.rtfd.org"
52+
53+
[tool.setuptools]
54+
package-data = { "wrf" = ["data/psadilookup.dat"]}
55+
platforms = ["any"]
56+
57+
[tool.setuptools.packages.find]
58+
where = ["src"]
59+
60+
[tool.setuptools.dynamic]
61+
version = { attr = "wrf.version.__version__" }

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
import os
2-
import sys
32
import setuptools
43
import socket
54

6-
# Bootstrap a numpy installation before trying to import it.
7-
import importlib
8-
try:
9-
numpy_module = importlib.util.find_spec('numpy')
10-
if numpy_module is None:
11-
raise ModuleNotFoundError
12-
except (ImportError, ModuleNotFoundError):
13-
import subprocess
14-
subprocess.call([sys.executable, '-m', 'pip', 'install', 'numpy'])
15-
165
if not socket.gethostname().startswith("cheyenne"):
176
import numpy.distutils.core
187
else:
@@ -53,70 +42,15 @@
5342
"fortran/omp.f90"]
5443
)
5544

56-
#Note: __version__ will be set in the version.py script loaded below
57-
__version__ = None
58-
with open("src/wrf/version.py") as f:
59-
exec(f.read())
60-
6145
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
6246
# on_rtd=True
6347
if on_rtd:
64-
if sys.version_info < (3, 3):
65-
requirements = ["mock"] # for python2 and python < 3.3
66-
else:
67-
requirements = [] # for >= python3.3
6848
ext_modules = []
6949

7050
else:
71-
# Place install_requires into the text file "requirements.txt"
72-
with open("requirements.txt") as f2:
73-
requirements = f2.read().strip().splitlines()
74-
75-
# if sys.version_info < (3,3):
76-
# requirements.append("mock")
7751
ext_modules = [ext1]
7852

7953
numpy.distutils.core.setup(
80-
name='wrf-python',
81-
author="Bill Ladwig",
82-
maintainer="GeoCAT",
83-
maintainer_email="[email protected]",
84-
description="Diagnostic and interpolation routines for WRF-ARW data.",
85-
long_description=("A collection of diagnostic and interpolation "
86-
"routines to be used with WRF-ARW data.\n\n"
87-
"GitHub Repository:\n\n"
88-
"https://github.com/NCAR/wrf-python\n\n"
89-
"Documentation:\n\n"
90-
"https://wrf-python.rtfd.org\n"),
91-
url="https://github.com/NCAR/wrf-python",
92-
version=__version__,
93-
package_dir={"": "src"},
94-
keywords=["python", "wrf-python", "wrf", "forecast", "model",
95-
"weather research and forecasting", "interpolation",
96-
"plotting", "plots", "meteorology", "nwp",
97-
"numerical weather prediction", "diagnostic",
98-
"science", "numpy"],
99-
python_requires='>=3.9, <3.12',
100-
install_requires=requirements,
101-
classifiers=["Development Status :: 5 - Production/Stable",
102-
"Intended Audience :: Science/Research",
103-
"Intended Audience :: Developers",
104-
"License :: OSI Approved :: Apache Software License",
105-
"Programming Language :: Fortran",
106-
"Programming Language :: Python :: 3.9",
107-
"Programming Language :: Python :: 3.10",
108-
"Programming Language :: Python :: 3.11",
109-
"Topic :: Scientific/Engineering :: Atmospheric Science",
110-
"Topic :: Software Development",
111-
"Operating System :: POSIX",
112-
"Operating System :: Unix",
113-
"Operating System :: MacOS",
114-
"Operating System :: Microsoft :: Windows"],
115-
platforms=["any"],
116-
license="Apache License 2.0",
117-
packages=setuptools.find_packages("src"),
11854
ext_modules=ext_modules,
119-
download_url="https://python.org/pypi/wrf-python",
120-
package_data={"wrf": ["data/psadilookup.dat"]},
12155
scripts=[]
12256
)

0 commit comments

Comments
 (0)