From d323dc0984a5cc9c0e962a634b5bf7c396b7e248 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 23 May 2024 16:10:08 -0400 Subject: [PATCH 01/13] 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. --- pyproject.toml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b5e8154 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,53 @@ +[build-system] +requires = ["setuptools", "numpy"] +build-backend = "setuptools.build_meta" + +[project] +name = "wrf-python" +authors = ["Bill Ladwig"] +maintainers = [ + { name = "GeoCAT", email = "geocat@ucar.edu" }, +] +description = "Diagnostic and interpolation routines for WRF-ARW data." +readme = "README.md" +requires-python = ">=3.7, <3.12" +keywords = [ + "python", "wrf-python", "wrf", "forecast", "model", + "weather research and forecasting", "interpolation", + "plotting", "plots", "meteorology", "nwp", + "numerical weather prediction", "diagnostic", + "science", "numpy" +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Fortran", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering :: Atmospheric Science", + "Topic :: Software Development", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows" +] +license = { text = "Apache-2.0", file = "LICENSE" } +dynamic = [ "version", "dependencies" ] + +[project.urls] +Repository = "https://github.com/NCAR/wrf-python" +Documentation = "https://wrf-python.rtfd.org" + +[tool.setuptools] +package-data = { "wrf" = ["data/psadilookup.dat"]} +platforms = ["any"] + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.dynamic] +version = { attr = "wrf.version.__version__" } +dependencies = { file = "requirements.txt" } From 8322c424885faad29ec16ad432284ca6aa72e280 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Thu, 23 May 2024 22:58:33 -0400 Subject: [PATCH 02/13] 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. --- pyproject.toml | 6 +++-- setup.py | 62 +------------------------------------------------- 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b5e8154..cebbf73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,9 @@ build-backend = "setuptools.build_meta" [project] name = "wrf-python" -authors = ["Bill Ladwig"] +authors = [ + { name = "Bill Ladwig" } +] maintainers = [ { name = "GeoCAT", email = "geocat@ucar.edu" }, ] @@ -34,7 +36,7 @@ classifiers = [ "Operating System :: MacOS", "Operating System :: Microsoft :: Windows" ] -license = { text = "Apache-2.0", file = "LICENSE" } +license = { text = "Apache-2.0" } dynamic = [ "version", "dependencies" ] [project.urls] diff --git a/setup.py b/setup.py index 9c38c9a..8fd210c 100755 --- a/setup.py +++ b/setup.py @@ -1,18 +1,7 @@ import os -import sys import setuptools import socket -# Bootstrap a numpy installation before trying to import it. -import importlib -try: - numpy_module = importlib.util.find_spec('numpy') - if numpy_module is None: - raise ModuleNotFoundError -except (ImportError, ModuleNotFoundError): - import subprocess - subprocess.call([sys.executable, '-m', 'pip', 'install', 'numpy']) - if not socket.gethostname().startswith("cheyenne"): import numpy.distutils.core else: @@ -53,18 +42,10 @@ "fortran/omp.f90"] ) -#Note: __version__ will be set in the version.py script loaded below -__version__ = None -with open("src/wrf/version.py") as f: - exec(f.read()) - on_rtd = os.environ.get("READTHEDOCS", None) == "True" # on_rtd=True if on_rtd: - if sys.version_info < (3, 3): - requirements = ["mock"] # for python2 and python < 3.3 - else: - requirements = [] # for >= python3.3 + requirements = ["mock; python_version < 3.3"] ext_modules = [] else: @@ -72,51 +53,10 @@ with open("requirements.txt") as f2: requirements = f2.read().strip().splitlines() - # if sys.version_info < (3,3): - # requirements.append("mock") ext_modules = [ext1] numpy.distutils.core.setup( - name='wrf-python', - author="Bill Ladwig", - maintainer="GeoCAT", - maintainer_email="geocat@ucar.edu", - description="Diagnostic and interpolation routines for WRF-ARW data.", - long_description=("A collection of diagnostic and interpolation " - "routines to be used with WRF-ARW data.\n\n" - "GitHub Repository:\n\n" - "https://github.com/NCAR/wrf-python\n\n" - "Documentation:\n\n" - "https://wrf-python.rtfd.org\n"), - url="https://github.com/NCAR/wrf-python", - version=__version__, - package_dir={"": "src"}, - keywords=["python", "wrf-python", "wrf", "forecast", "model", - "weather research and forecasting", "interpolation", - "plotting", "plots", "meteorology", "nwp", - "numerical weather prediction", "diagnostic", - "science", "numpy"], - python_requires='>=3.7', install_requires=requirements, - classifiers=["Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Fortran", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Scientific/Engineering :: Atmospheric Science", - "Topic :: Software Development", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows"], - platforms=["any"], - license="Apache License 2.0", - packages=setuptools.find_packages("src"), ext_modules=ext_modules, - download_url="https://python.org/pypi/wrf-python", - package_data={"wrf": ["data/psadilookup.dat"]}, scripts=[] ) From 5c169ebf1a2fe8a5440f1712cd31f9e234c8af11 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 24 May 2024 06:53:01 -0400 Subject: [PATCH 03/13] 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. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cebbf73..b5f078c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "numpy"] +requires = ["setuptools>=60", "numpy"] build-backend = "setuptools.build_meta" [project] From c854ae9820888c9d02a3b1ec1689f57ac157d577 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Sun, 26 May 2024 08:49:47 -0400 Subject: [PATCH 04/13] BLD: Quote version requirement. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8fd210c..6033410 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ on_rtd = os.environ.get("READTHEDOCS", None) == "True" # on_rtd=True if on_rtd: - requirements = ["mock; python_version < 3.3"] + requirements = ['mock; python_version < "3.3"'] ext_modules = [] else: From a3f5263e45dc50ddd96c1713c6e038fc6d8d16e5 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 27 May 2024 08:30:08 -0400 Subject: [PATCH 05/13] BLD: Specify dependencies in pyproject.toml only. Remove requirements.txt. --- MANIFEST.in | 1 - pyproject.toml | 12 +++++++++--- requirements.txt | 5 ----- setup.py | 5 ----- 4 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index 79b786b..44c6fbd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,5 @@ include README.md include LICENSE -include requirements.txt include fortran/*.f90 include fortran/*.pyf diff --git a/pyproject.toml b/pyproject.toml index b5f078c..810a510 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=60", "numpy"] +requires = ["setuptools>=61", "numpy"] build-backend = "setuptools.build_meta" [project] @@ -37,7 +37,14 @@ classifiers = [ "Operating System :: Microsoft :: Windows" ] license = { text = "Apache-2.0" } -dynamic = [ "version", "dependencies" ] +dynamic = [ "version" ] +dependencies = [ + "basemap", + "numpy >=1.11, !=1.24.3", + "setuptools", + "wrapt", + "xarray" +] [project.urls] Repository = "https://github.com/NCAR/wrf-python" @@ -52,4 +59,3 @@ where = ["src"] [tool.setuptools.dynamic] version = { attr = "wrf.version.__version__" } -dependencies = { file = "requirements.txt" } diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e9cbcfa..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -basemap -numpy >=1.11, !=1.24.3 -setuptools -wrapt -xarray diff --git a/setup.py b/setup.py index 6033410..959885d 100755 --- a/setup.py +++ b/setup.py @@ -45,14 +45,9 @@ on_rtd = os.environ.get("READTHEDOCS", None) == "True" # on_rtd=True if on_rtd: - requirements = ['mock; python_version < "3.3"'] ext_modules = [] else: - # Place install_requires into the text file "requirements.txt" - with open("requirements.txt") as f2: - requirements = f2.read().strip().splitlines() - ext_modules = [ext1] numpy.distutils.core.setup( From 116ab31a36df83621daabc1d27781f2d64362ce1 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 28 May 2024 10:20:40 -0400 Subject: [PATCH 06/13] 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. --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index d059c2c..8cb6480 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,7 +11,7 @@ build: python: "mambaforge-4.10" jobs: post_create_environment: - - python -m pip install --no-cache-dir . + - python -m pip install --no-cache-dir --no-deps . # Build documentation in the docs/ directory with Sphinx sphinx: From c86c10893d02e4bb5531f5cd110ab1c585ea34a9 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 29 May 2024 14:50:40 -0400 Subject: [PATCH 07/13] BLD,BUG: Remove references to requirements, not just definitions Forgot to remove this two or three commits back. --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 959885d..eaa0f91 100755 --- a/setup.py +++ b/setup.py @@ -51,7 +51,6 @@ ext_modules = [ext1] numpy.distutils.core.setup( - install_requires=requirements, ext_modules=ext_modules, scripts=[] ) From fd9d787fafba69a83882fa1d5bfd3be260aa78dc Mon Sep 17 00:00:00 2001 From: erogluorhan Date: Fri, 2 Aug 2024 01:16:35 -0600 Subject: [PATCH 08/13] Try handling ci.yml in a platform specific way --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f40dfd..cc04eaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ "ubuntu-latest", "macos-latest", "macos-14" ] + os: [ "ubuntu-latest", "macos-latest" ] python-version: [ "3.9", "3.10", "3.11" ] steps: @@ -32,16 +32,16 @@ jobs: uses: actions/checkout@v4 with: token: ${{ github.token }} - - name: Conda setup + - name: Conda setup (ubuntu) uses: conda-incubator/setup-miniconda@v3 - if: matrix.os != 'macos-14' + if: matrix.os == 'ubuntu-latest' with: python-version: ${{ matrix.python-version }} channels: conda-forge - environment-file: build_envs/environment.yml + environment-file: build_envs/platform-specific/linux.yml - name: Conda setup (macOS M1) uses: conda-incubator/setup-miniconda@v3 - if: matrix.os == 'macos-14' + if: matrix.os == 'macos-latest' with: installer-url: https://github.com/conda-forge/miniforge/releases/download/23.11.0-0/Mambaforge-23.11.0-0-MacOSX-arm64.sh python-version: ${{ matrix.python-version }} From 78089414171bc158ca918a1707472dd2f85ee31a Mon Sep 17 00:00:00 2001 From: erogluorhan Date: Fri, 2 Aug 2024 01:16:59 -0600 Subject: [PATCH 09/13] Add python>=3.9 into linux.yml --- build_envs/platform-specific/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_envs/platform-specific/linux.yml b/build_envs/platform-specific/linux.yml index c348960..af4cebe 100644 --- a/build_envs/platform-specific/linux.yml +++ b/build_envs/platform-specific/linux.yml @@ -3,7 +3,7 @@ name: wrf_python_build channels: - conda-forge dependencies: - - python<3.12 + - python>=3.9, <3.12 - basemap - cartopy - gcc_linux-64 From 1df89a8c31cda53c236725d2a448aff4730fcdf3 Mon Sep 17 00:00:00 2001 From: erogluorhan Date: Fri, 2 Aug 2024 01:38:36 -0600 Subject: [PATCH 10/13] Add conda list to ci.yml for diagnosis --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc04eaf..231f18b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,9 @@ jobs: python-version: ${{ matrix.python-version }} channels: conda-forge environment-file: build_envs/environment.yml + - name: Conda list + run: | + conda list - name: Build WRF-Python run: | cd build_scripts From a3b3de5ab62fdc265b8714041ac9b7c646646c4f Mon Sep 17 00:00:00 2001 From: erogluorhan Date: Fri, 2 Aug 2024 01:57:02 -0600 Subject: [PATCH 11/13] Install ubuntu-latest env from environment.yml as well --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 231f18b..2a01ae8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: with: python-version: ${{ matrix.python-version }} channels: conda-forge - environment-file: build_envs/platform-specific/linux.yml + environment-file: build_envs/environment.yml - name: Conda setup (macOS M1) uses: conda-incubator/setup-miniconda@v3 if: matrix.os == 'macos-latest' From 65666f107485bae86272032b5fb333e6c9531692 Mon Sep 17 00:00:00 2001 From: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:10:23 -0600 Subject: [PATCH 12/13] Update pyproject.toml build-system requirements --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 810a510..d9f6511 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ [build-system] -requires = ["setuptools>=61", "numpy"] build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=61", + "setuptools-scm>=8", +] [project] name = "wrf-python" @@ -57,5 +60,8 @@ platforms = ["any"] [tool.setuptools.packages.find] where = ["src"] +[tool.setuptools_scm] +fallback_version = "9999" + [tool.setuptools.dynamic] version = { attr = "wrf.version.__version__" } From ecc55e3fc7669c478f1c501443bdbb7c45baa246 Mon Sep 17 00:00:00 2001 From: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:15:31 -0600 Subject: [PATCH 13/13] Update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index d9f6511..ad27702 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools>=61", "setuptools-scm>=8", + "numpy", ] [project]