diff --git a/conda_package/LICENSE b/conda_package/LICENSE new file mode 120000 index 000000000..ea5b60640 --- /dev/null +++ b/conda_package/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/conda_package/MANIFEST.in b/conda_package/MANIFEST.in deleted file mode 100644 index cc189a12a..000000000 --- a/conda_package/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -recursive-include mpas_tools *.xml -recursive-include mpas_tools *.cmake -recursive-include mpas_tools *.yaml diff --git a/conda_package/README.md b/conda_package/README.md new file mode 120000 index 000000000..32d46ee88 --- /dev/null +++ b/conda_package/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/conda_package/ci/linux_64_python3.11.____cpython.yaml b/conda_package/ci/linux_64_python3.11.____cpython.yaml index da7935efd..879d626a5 100644 --- a/conda_package/ci/linux_64_python3.11.____cpython.yaml +++ b/conda_package/ci/linux_64_python3.11.____cpython.yaml @@ -1,3 +1,5 @@ +DOCKER_PLATFORM: +- linux/amd64 c_stdlib: - sysroot c_stdlib_version: @@ -9,17 +11,17 @@ channel_targets: cxx_compiler: - gxx cxx_compiler_version: -- '14' +- '15' docker_image: -- quay.io/condaforge/linux-anvil-x86_64:alma9 +- quay.io/condaforge/linux-anvil-x86_64:alma10 fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 netcdf_fortran: - '4.6' pin_run_as_build: diff --git a/conda_package/ci/linux_64_python3.12.____cpython.yaml b/conda_package/ci/linux_64_python3.12.____cpython.yaml index 2318a5ff6..2c6375c21 100644 --- a/conda_package/ci/linux_64_python3.12.____cpython.yaml +++ b/conda_package/ci/linux_64_python3.12.____cpython.yaml @@ -1,3 +1,5 @@ +DOCKER_PLATFORM: +- linux/amd64 c_stdlib: - sysroot c_stdlib_version: @@ -9,17 +11,17 @@ channel_targets: cxx_compiler: - gxx cxx_compiler_version: -- '14' +- '15' docker_image: -- quay.io/condaforge/linux-anvil-x86_64:alma9 +- quay.io/condaforge/linux-anvil-x86_64:alma10 fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 netcdf_fortran: - '4.6' pin_run_as_build: diff --git a/conda_package/ci/linux_64_python3.13.____cpython.yaml b/conda_package/ci/linux_64_python3.13.____cpython.yaml index 7be44023f..f53ee920d 100644 --- a/conda_package/ci/linux_64_python3.13.____cpython.yaml +++ b/conda_package/ci/linux_64_python3.13.____cpython.yaml @@ -1,3 +1,5 @@ +DOCKER_PLATFORM: +- linux/amd64 c_stdlib: - sysroot c_stdlib_version: @@ -9,17 +11,17 @@ channel_targets: cxx_compiler: - gxx cxx_compiler_version: -- '14' +- '15' docker_image: -- quay.io/condaforge/linux-anvil-x86_64:alma9 +- quay.io/condaforge/linux-anvil-x86_64:alma10 fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 netcdf_fortran: - '4.6' pin_run_as_build: diff --git a/conda_package/ci/linux_64_python3.14.____cpython.yaml b/conda_package/ci/linux_64_python3.14.____cpython.yaml index 6c5195cd4..f6d306ce8 100644 --- a/conda_package/ci/linux_64_python3.14.____cpython.yaml +++ b/conda_package/ci/linux_64_python3.14.____cpython.yaml @@ -1,3 +1,5 @@ +DOCKER_PLATFORM: +- linux/amd64 c_stdlib: - sysroot c_stdlib_version: @@ -9,17 +11,17 @@ channel_targets: cxx_compiler: - gxx cxx_compiler_version: -- '14' +- '15' docker_image: -- quay.io/condaforge/linux-anvil-x86_64:alma9 +- quay.io/condaforge/linux-anvil-x86_64:alma10 fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 netcdf_fortran: - '4.6' pin_run_as_build: diff --git a/conda_package/ci/osx_64_python3.11.____cpython.yaml b/conda_package/ci/osx_64_python3.11.____cpython.yaml index 010752123..454edcbc2 100644 --- a/conda_package/ci/osx_64_python3.11.____cpython.yaml +++ b/conda_package/ci/osx_64_python3.11.____cpython.yaml @@ -1,5 +1,3 @@ -MACOSX_DEPLOYMENT_TARGET: -- '11.0' MACOSX_SDK_VERSION: - '11.0' c_stdlib: @@ -13,17 +11,17 @@ channel_targets: cxx_compiler: - clangxx cxx_compiler_version: -- '19' +- '21' fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 llvm_openmp: -- '19' +- '21' macos_machine: - x86_64-apple-darwin13.4.0 netcdf_fortran: diff --git a/conda_package/ci/osx_64_python3.12.____cpython.yaml b/conda_package/ci/osx_64_python3.12.____cpython.yaml index 039135a03..2a7860040 100644 --- a/conda_package/ci/osx_64_python3.12.____cpython.yaml +++ b/conda_package/ci/osx_64_python3.12.____cpython.yaml @@ -1,5 +1,3 @@ -MACOSX_DEPLOYMENT_TARGET: -- '11.0' MACOSX_SDK_VERSION: - '11.0' c_stdlib: @@ -13,17 +11,17 @@ channel_targets: cxx_compiler: - clangxx cxx_compiler_version: -- '19' +- '21' fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 llvm_openmp: -- '19' +- '21' macos_machine: - x86_64-apple-darwin13.4.0 netcdf_fortran: diff --git a/conda_package/ci/osx_64_python3.13.____cpython.yaml b/conda_package/ci/osx_64_python3.13.____cpython.yaml index 4c87bf008..db8f633db 100644 --- a/conda_package/ci/osx_64_python3.13.____cpython.yaml +++ b/conda_package/ci/osx_64_python3.13.____cpython.yaml @@ -1,5 +1,3 @@ -MACOSX_DEPLOYMENT_TARGET: -- '11.0' MACOSX_SDK_VERSION: - '11.0' c_stdlib: @@ -13,17 +11,17 @@ channel_targets: cxx_compiler: - clangxx cxx_compiler_version: -- '19' +- '21' fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 llvm_openmp: -- '19' +- '21' macos_machine: - x86_64-apple-darwin13.4.0 netcdf_fortran: diff --git a/conda_package/ci/osx_64_python3.14.____cpython.yaml b/conda_package/ci/osx_64_python3.14.____cpython.yaml index 7314dc4d5..7670d072b 100644 --- a/conda_package/ci/osx_64_python3.14.____cpython.yaml +++ b/conda_package/ci/osx_64_python3.14.____cpython.yaml @@ -1,5 +1,3 @@ -MACOSX_DEPLOYMENT_TARGET: -- '11.0' MACOSX_SDK_VERSION: - '11.0' c_stdlib: @@ -13,17 +11,17 @@ channel_targets: cxx_compiler: - clangxx cxx_compiler_version: -- '19' +- '21' fortran_compiler: - gfortran fortran_compiler_version: -- '14' +- '15' hdf5: -- 1.14.6 +- '2' libnetcdf: -- 4.10.0 +- 4.10.1 llvm_openmp: -- '19' +- '21' macos_machine: - x86_64-apple-darwin13.4.0 netcdf_fortran: diff --git a/conda_package/dev-spec.txt b/conda_package/dev-spec.txt index 7ac655e9a..78a437c1b 100644 --- a/conda_package/dev-spec.txt +++ b/conda_package/dev-spec.txt @@ -36,7 +36,7 @@ pre-commit pytest pyyaml ruff -setuptools +setuptools >=77 # Documentation sphinx diff --git a/conda_package/pixi.toml b/conda_package/pixi.toml index 7ec34c83c..be7a647a9 100644 --- a/conda_package/pixi.toml +++ b/conda_package/pixi.toml @@ -36,7 +36,7 @@ pre-commit = "*" pytest = "*" pyyaml = "*" ruff = "*" -setuptools = "*" +setuptools = ">=77" rattler-build = "*" sphinx = "*" mock = "*" diff --git a/conda_package/pyproject.toml b/conda_package/pyproject.toml index b8a01b14b..4b41919b2 100644 --- a/conda_package/pyproject.toml +++ b/conda_package/pyproject.toml @@ -32,10 +32,12 @@ authors = [ { name="Riley Brady" }, ] description = """\ - A set of tools for creating and manipulating meshes for the climate - components based on the Model for Prediction Across Scales (MPAS) framework + A set of tools for creating and manipulating meshes for the climate \ + components based on the Model for Prediction Across Scales (MPAS) \ + framework\ """ -license = { file = "LICENSE" } +license = "BSD-3-Clause" +license-files = ["LICENSE"] readme = "README.md" requires-python = ">=3.11" classifiers = [ @@ -45,7 +47,6 @@ classifiers = [ "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Intended Audience :: Science/Research", "Topic :: Scientific/Engineering", @@ -121,11 +122,18 @@ max-complexity = 18 convention = "numpy" [build-system] -requires = ["setuptools>=60"] +requires = ["setuptools>=77"] build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] -exclude = ["ci*", "docs*", "recipe*"] +# an allow-list so that only mpas_tools ends up in site-packages (not tests, +# docs or stray directories picked up as namespace packages) +include = ["mpas_tools", "mpas_tools.*"] + +[tool.setuptools.package-data] +# tests/test_packaging.py checks that these patterns match every non-Python +# file under mpas_tools that git tracks +mpas_tools = ["**/*.bib", "**/*.cmake", "**/*.xml", "**/*.yaml"] [tool.setuptools.dynamic] version = { attr = "mpas_tools.__init__.__version__" } diff --git a/conda_package/recipe/build.sh b/conda_package/recipe/build.sh index 28f4565fa..7f33d1d24 100644 --- a/conda_package/recipe/build.sh +++ b/conda_package/recipe/build.sh @@ -10,7 +10,7 @@ ${PYTHON} -m pip install . --no-deps --no-build-isolation -vv cd ${SRC_DIR}/ocean/smooth_topo mkdir build cd build -cmake \ +cmake ${CMAKE_ARGS} \ -D CMAKE_INSTALL_PREFIX=${PREFIX} \ -D CMAKE_BUILD_TYPE=Release \ .. @@ -21,7 +21,7 @@ cmake --install . cd ${SRC_DIR}/mesh_tools/seaice_grid_tools mkdir build cd build -cmake \ +cmake ${CMAKE_ARGS} \ -D CMAKE_INSTALL_PREFIX=${PREFIX} \ -D CMAKE_BUILD_TYPE=Release \ .. @@ -32,7 +32,7 @@ cmake --install . cd ${SRC_DIR}/mesh_tools/mesh_conversion_tools mkdir build cd build -cmake \ +cmake ${CMAKE_ARGS} \ -D CMAKE_INSTALL_PREFIX=${PREFIX} \ -D CMAKE_BUILD_TYPE=Release \ .. @@ -43,7 +43,7 @@ cp MpasMaskCreator.x ${PREFIX}/bin cd ${SRC_DIR}/mesh_tools/mesh_conversion_tools_netcdf_c mkdir build cd build -cmake \ +cmake ${CMAKE_ARGS} \ -D CMAKE_INSTALL_PREFIX=${PREFIX} \ -D CMAKE_BUILD_TYPE=Release \ .. diff --git a/conda_package/recipe/recipe.yaml b/conda_package/recipe/recipe.yaml index 255df9477..7228cf745 100644 --- a/conda_package/recipe/recipe.yaml +++ b/conda_package/recipe/recipe.yaml @@ -35,9 +35,8 @@ requirements: - libnetcdf * nompi_* - netcdf-fortran - netcdf-fortran * nompi_* - - setuptools + - setuptools >=77 - pip - - netcdf4 - if: osx then: llvm-openmp run: diff --git a/conda_package/tests/test_dependencies.py b/conda_package/tests/test_dependencies.py index bbc6bd231..30b5c2f71 100644 --- a/conda_package/tests/test_dependencies.py +++ b/conda_package/tests/test_dependencies.py @@ -33,6 +33,7 @@ # conda-forge package names that differ from their PyPI equivalents CONDA_TO_PYPI = { + 'dask-core': 'dask', 'matplotlib-base': 'matplotlib', 'python-igraph': 'igraph', } diff --git a/conda_package/tests/test_packaging.py b/conda_package/tests/test_packaging.py new file mode 100644 index 000000000..0c0b66549 --- /dev/null +++ b/conda_package/tests/test_packaging.py @@ -0,0 +1,68 @@ +""" +Tests that the ``[tool.setuptools.package-data]`` patterns in +``pyproject.toml`` match every non-Python file under ``mpas_tools`` that git +tracks, so no data file is silently left out of the package. +""" + +import shutil +import subprocess +import tomllib +from pathlib import Path + +import pytest + +CONDA_PACKAGE_DIR = Path(__file__).resolve().parents[1] +PYPROJECT = CONDA_PACKAGE_DIR / 'pyproject.toml' +PACKAGE_DIR = CONDA_PACKAGE_DIR / 'mpas_tools' + + +def _git_tracked_package_files(): + """ + Get the files under ``mpas_tools`` that git tracks, relative to the + package directory, or ``None`` if this is not a git checkout + """ + if shutil.which('git') is None or not PACKAGE_DIR.is_dir(): + return None + result = subprocess.run( + ['git', 'ls-files', '-z', '.'], + cwd=PACKAGE_DIR, + capture_output=True, + text=True, + check=False, + ) + if result.returncode != 0: + return None + files = {Path(name) for name in result.stdout.split('\0') if name} + return files or None + + +TRACKED_FILES = _git_tracked_package_files() + +# skip these tests when they are run from the conda package rather than from +# a source checkout +pytestmark = pytest.mark.skipif( + not PYPROJECT.exists() or TRACKED_FILES is None, + reason='package data can only be checked in a git source checkout', +) + + +def test_package_data_patterns_match_tracked_files(): + with open(PYPROJECT, 'rb') as f: + pyproject = tomllib.load(f) + patterns = pyproject['tool']['setuptools']['package-data']['mpas_tools'] + + matched = set() + for pattern in patterns: + matched.update( + path.relative_to(PACKAGE_DIR) + for path in PACKAGE_DIR.glob(pattern) + if path.is_file() + ) + + data_files = {path for path in TRACKED_FILES if path.suffix != '.py'} + missing = sorted(str(path) for path in data_files - matched) + assert not missing, ( + 'These files tracked by git are not matched by the package-data ' + 'patterns in pyproject.toml, so they would be left out of the ' + f'package: {missing}' + )