skyborn-backend 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- skyborn_backend-0.1.0/LICENSE +29 -0
- skyborn_backend-0.1.0/PKG-INFO +75 -0
- skyborn_backend-0.1.0/README.md +42 -0
- skyborn_backend-0.1.0/pyproject.toml +101 -0
- skyborn_backend-0.1.0/setup.cfg +4 -0
- skyborn_backend-0.1.0/setup.py +374 -0
- skyborn_backend-0.1.0/src/skyborn_backend.egg-info/PKG-INFO +75 -0
- skyborn_backend-0.1.0/src/skyborn_backend.egg-info/SOURCES.txt +25 -0
- skyborn_backend-0.1.0/src/skyborn_backend.egg-info/dependency_links.txt +1 -0
- skyborn_backend-0.1.0/src/skyborn_backend.egg-info/requires.txt +4 -0
- skyborn_backend-0.1.0/src/skyborn_backend.egg-info/top_level.txt +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/__init__.py +4 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/GPI/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/cape/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/causality/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/dcape/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/filter/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/geostrophic/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/growth_rate/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/mann_kendall/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/srh/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/calc/troposphere/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/gridfill/__init__.py +1 -0
- skyborn_backend-0.1.0/src/skybornbackend/interp/__init__.py +1 -0
- skyborn_backend-0.1.0/tests/test_backend_imports.py +49 -0
- skyborn_backend-0.1.0/tests/test_setup_build_tools.py +63 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Qianye Su
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the [copyright holder] nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: skyborn-backend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compiled Fortran, C, and Cython computational kernels for Skyborn
|
|
5
|
+
Author-email: Qianye Su <suqianye2000@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/skyborn-org/skyborn-backend
|
|
8
|
+
Project-URL: Repository, https://github.com/skyborn-org/skyborn-backend
|
|
9
|
+
Project-URL: Documentation, https://skyborn.readthedocs.io/
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/skyborn-org/skyborn-backend/issues
|
|
11
|
+
Keywords: atmospheric-science,meteorology,climate,fortran,kernels
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Operating System :: MacOS
|
|
24
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
25
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# skyborn-backend (`skybornbackend`)
|
|
35
|
+
|
|
36
|
+
Prebuilt Fortran, C, and Cython numerical computation kernels powering the [**Skyborn**](https://github.com/skyborn-org/Skyborn) atmospheric and climate science ecosystem.
|
|
37
|
+
|
|
38
|
+
Part of the [**Skyborn** (`skyborn-org`)](https://github.com/skyborn-org) organization.
|
|
39
|
+
|
|
40
|
+
## Included Compiled Modules
|
|
41
|
+
|
|
42
|
+
- `skybornbackend.gridfill`: Poisson spherical/rectangular gap-filling (`_gridfill`).
|
|
43
|
+
- `skybornbackend.interp`: Vertical hybrid/pressure/isentropic interpolation, horizontal bilinear/conserving regridding, and curvilinear-to-rectilinear kernels.
|
|
44
|
+
- `skybornbackend.calc`:
|
|
45
|
+
- `GPI`: Potential intensity kernels (`tropical_cyclone_potential_intensity`)
|
|
46
|
+
- `cape` & `dcape`: Convective and downdraft CAPE kernels
|
|
47
|
+
- `causality`: Batch Liang–Kleeman information flow & AR(1) kernels
|
|
48
|
+
- `filter`: Lanczos filtering Fortran kernels
|
|
49
|
+
- `geostrophic`: Geostrophic wind solver (`geostrophicwind`)
|
|
50
|
+
- `growth_rate`: Eady baroclinic & barotropic growth rate kernels
|
|
51
|
+
- `mann_kendall`: Vectorized multidimensional Mann–Kendall & Theil–Sen kernels
|
|
52
|
+
- `srh`: Storm-relative helicity kernels
|
|
53
|
+
- `troposphere`: WMO tropopause height kernels
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Most users should install the high-level library instead, which pulls this package automatically:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install skyborn
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Developer Incremental Build Tips
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# First inplace build compiles all 12 Meson modules:
|
|
67
|
+
python setup.py build_ext --inplace
|
|
68
|
+
|
|
69
|
+
# Subsequent edits reuse Ninja caches; optionally target a single module:
|
|
70
|
+
SKYBORN_BUILD_ONLY=calc.mann_kendall python setup.py build_ext --inplace
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
BSD 3-Clause License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# skyborn-backend (`skybornbackend`)
|
|
2
|
+
|
|
3
|
+
Prebuilt Fortran, C, and Cython numerical computation kernels powering the [**Skyborn**](https://github.com/skyborn-org/Skyborn) atmospheric and climate science ecosystem.
|
|
4
|
+
|
|
5
|
+
Part of the [**Skyborn** (`skyborn-org`)](https://github.com/skyborn-org) organization.
|
|
6
|
+
|
|
7
|
+
## Included Compiled Modules
|
|
8
|
+
|
|
9
|
+
- `skybornbackend.gridfill`: Poisson spherical/rectangular gap-filling (`_gridfill`).
|
|
10
|
+
- `skybornbackend.interp`: Vertical hybrid/pressure/isentropic interpolation, horizontal bilinear/conserving regridding, and curvilinear-to-rectilinear kernels.
|
|
11
|
+
- `skybornbackend.calc`:
|
|
12
|
+
- `GPI`: Potential intensity kernels (`tropical_cyclone_potential_intensity`)
|
|
13
|
+
- `cape` & `dcape`: Convective and downdraft CAPE kernels
|
|
14
|
+
- `causality`: Batch Liang–Kleeman information flow & AR(1) kernels
|
|
15
|
+
- `filter`: Lanczos filtering Fortran kernels
|
|
16
|
+
- `geostrophic`: Geostrophic wind solver (`geostrophicwind`)
|
|
17
|
+
- `growth_rate`: Eady baroclinic & barotropic growth rate kernels
|
|
18
|
+
- `mann_kendall`: Vectorized multidimensional Mann–Kendall & Theil–Sen kernels
|
|
19
|
+
- `srh`: Storm-relative helicity kernels
|
|
20
|
+
- `troposphere`: WMO tropopause height kernels
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Most users should install the high-level library instead, which pulls this package automatically:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install skyborn
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Developer Incremental Build Tips
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# First inplace build compiles all 12 Meson modules:
|
|
34
|
+
python setup.py build_ext --inplace
|
|
35
|
+
|
|
36
|
+
# Subsequent edits reuse Ninja caches; optionally target a single module:
|
|
37
|
+
SKYBORN_BUILD_ONLY=calc.mann_kendall python setup.py build_ext --inplace
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
BSD 3-Clause License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=61.0",
|
|
4
|
+
"wheel",
|
|
5
|
+
"numpy>=1.24.0",
|
|
6
|
+
"Cython>=3.0.0",
|
|
7
|
+
"meson",
|
|
8
|
+
"ninja",
|
|
9
|
+
]
|
|
10
|
+
build-backend = "setuptools.build_meta"
|
|
11
|
+
|
|
12
|
+
[project]
|
|
13
|
+
name = "skyborn-backend"
|
|
14
|
+
dynamic = ["version"]
|
|
15
|
+
description = "Compiled Fortran, C, and Cython computational kernels for Skyborn"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
authors = [{ name = "Qianye Su", email = "suqianye2000@gmail.com" }]
|
|
18
|
+
license = "BSD-3-Clause"
|
|
19
|
+
license-files = ["LICENSE"]
|
|
20
|
+
requires-python = ">=3.9"
|
|
21
|
+
keywords = [
|
|
22
|
+
"atmospheric-science",
|
|
23
|
+
"meteorology",
|
|
24
|
+
"climate",
|
|
25
|
+
"fortran",
|
|
26
|
+
"kernels",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Intended Audience :: Science/Research",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Atmospheric Science",
|
|
32
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.9",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13",
|
|
39
|
+
"Programming Language :: Python :: 3.14",
|
|
40
|
+
"Operating System :: MacOS",
|
|
41
|
+
"Operating System :: Microsoft :: Windows",
|
|
42
|
+
"Operating System :: POSIX :: Linux",
|
|
43
|
+
]
|
|
44
|
+
dependencies = [
|
|
45
|
+
"numpy>=1.24.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
dev = [
|
|
50
|
+
"pytest>=7.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
"Homepage" = "https://github.com/skyborn-org/skyborn-backend"
|
|
55
|
+
"Repository" = "https://github.com/skyborn-org/skyborn-backend"
|
|
56
|
+
"Documentation" = "https://skyborn.readthedocs.io/"
|
|
57
|
+
"Bug Tracker" = "https://github.com/skyborn-org/skyborn-backend/issues"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools]
|
|
60
|
+
package-dir = { "" = "src" }
|
|
61
|
+
include-package-data = false
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.packages.find]
|
|
64
|
+
where = ["src"]
|
|
65
|
+
exclude = [
|
|
66
|
+
"*.build*",
|
|
67
|
+
"*.build*.*",
|
|
68
|
+
"*.build",
|
|
69
|
+
"*.build.*",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.setuptools.exclude-package-data]
|
|
73
|
+
"*" = [
|
|
74
|
+
"*.pyc",
|
|
75
|
+
"*.pyo",
|
|
76
|
+
"__pycache__/*",
|
|
77
|
+
"build/*",
|
|
78
|
+
"build_local/*",
|
|
79
|
+
"meson-private/*",
|
|
80
|
+
"meson-logs/*",
|
|
81
|
+
"meson-info/*",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.setuptools.dynamic]
|
|
85
|
+
version = { attr = "skybornbackend.__version__" }
|
|
86
|
+
|
|
87
|
+
[tool.black]
|
|
88
|
+
line-length = 88
|
|
89
|
+
target-version = ["py39", "py310", "py311", "py312", "py313", "py314"]
|
|
90
|
+
|
|
91
|
+
[tool.isort]
|
|
92
|
+
profile = "black"
|
|
93
|
+
line_length = 88
|
|
94
|
+
src_paths = ["src", "tests"]
|
|
95
|
+
|
|
96
|
+
[tool.pytest.ini_options]
|
|
97
|
+
minversion = "6.0"
|
|
98
|
+
testpaths = ["tests"]
|
|
99
|
+
python_files = ["test_*.py"]
|
|
100
|
+
python_classes = ["Test*"]
|
|
101
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"""Setup script for skyborn-backend with incremental Ninja builds and SKYBORN_BUILD_ONLY."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import platform
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from setuptools import Distribution, setup
|
|
14
|
+
from setuptools.command.build_ext import build_ext
|
|
15
|
+
from setuptools.command.develop import develop
|
|
16
|
+
from setuptools.command.install import install
|
|
17
|
+
from setuptools.command.install_lib import install_lib
|
|
18
|
+
from wheel.bdist_wheel import bdist_wheel
|
|
19
|
+
|
|
20
|
+
CONDA_BUILD_MODE = os.environ.get("CONDA_BUILD") == "1"
|
|
21
|
+
OPTIONAL_MESON_MODULE_FLAGS = {
|
|
22
|
+
"calc.growth_rate": "SKYBORN_BUILD_GROWTH_RATE",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _env_flag_enabled(name: str, default: str = "1") -> bool:
|
|
27
|
+
return os.environ.get(name, default).strip().lower() not in {"0", "false", "no", "off"}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _active_python_prefix() -> Path:
|
|
31
|
+
return Path(sys.prefix).resolve()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _parse_build_only_filter() -> set[str] | None:
|
|
35
|
+
raw = os.environ.get("SKYBORN_BUILD_ONLY", "").strip()
|
|
36
|
+
if not raw:
|
|
37
|
+
return None
|
|
38
|
+
return {item.strip() for item in raw.split(",") if item.strip()}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def configure_compiler_environment():
|
|
42
|
+
if CONDA_BUILD_MODE:
|
|
43
|
+
return
|
|
44
|
+
if platform.system() == "Darwin" and "CC" not in os.environ:
|
|
45
|
+
fc_path = shutil.which(os.environ.get("FC", "gfortran"))
|
|
46
|
+
if fc_path and ("/opt/homebrew" in fc_path or "/usr/local" in fc_path):
|
|
47
|
+
fc_dir = Path(fc_path).resolve().parent
|
|
48
|
+
gcc_bins = sorted(fc_dir.glob("gcc-[0-9]*"))
|
|
49
|
+
if not gcc_bins:
|
|
50
|
+
gcc_bins = sorted(Path("/opt/homebrew/bin").glob("gcc-[0-9]*"))
|
|
51
|
+
if gcc_bins:
|
|
52
|
+
cc_bin = str(gcc_bins[-1])
|
|
53
|
+
os.environ["CC"] = cc_bin
|
|
54
|
+
cxx_bin = cc_bin.replace("/gcc-", "/g++-")
|
|
55
|
+
if os.path.exists(cxx_bin):
|
|
56
|
+
os.environ.setdefault("CXX", cxx_bin)
|
|
57
|
+
os.environ.setdefault("FC", "gfortran")
|
|
58
|
+
os.environ.setdefault("F77", os.environ["FC"])
|
|
59
|
+
os.environ.setdefault("F90", os.environ["FC"])
|
|
60
|
+
os.environ.setdefault("CC", "gcc")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
configure_compiler_environment()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class MesonBuildExt(build_ext):
|
|
67
|
+
"""Build backend Meson modules with incremental caching and selective filtering."""
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def _resolve_tool_command(executable_name: str, module_name: str, *args: str):
|
|
71
|
+
executable_path = shutil.which(executable_name)
|
|
72
|
+
if executable_path:
|
|
73
|
+
return [executable_path, *args]
|
|
74
|
+
return [sys.executable, "-m", module_name, *args]
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def _meson_command(*args: str):
|
|
78
|
+
return MesonBuildExt._resolve_tool_command(
|
|
79
|
+
"meson", "mesonbuild.mesonmain", *args
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def _ninja_command(*args: str):
|
|
84
|
+
return MesonBuildExt._resolve_tool_command("ninja", "ninja", *args)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def _write_meson_native_file(build_dir: Path) -> Path:
|
|
88
|
+
native_file = (build_dir / "meson-python-native.ini").resolve()
|
|
89
|
+
python_executable = Path(os.path.abspath(sys.executable)).as_posix()
|
|
90
|
+
native_file.write_text(
|
|
91
|
+
"[binaries]\n"
|
|
92
|
+
f"python = '{python_executable}'\n"
|
|
93
|
+
f"build_python = '{python_executable}'\n",
|
|
94
|
+
encoding="utf-8",
|
|
95
|
+
)
|
|
96
|
+
return native_file
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def _write_build_python_shim(build_dir: Path) -> Path:
|
|
100
|
+
python_executable = shutil.which("python") or os.path.abspath(sys.executable)
|
|
101
|
+
if os.name == "nt":
|
|
102
|
+
shim_path = (build_dir / "build_python.bat").resolve()
|
|
103
|
+
with shim_path.open("w", encoding="utf-8", newline="\r\n") as handle:
|
|
104
|
+
handle.write("@echo off\r\n")
|
|
105
|
+
handle.write(f'"{python_executable}" %*\r\n')
|
|
106
|
+
else:
|
|
107
|
+
shim_path = (build_dir / "build_python").resolve()
|
|
108
|
+
python_executable = Path(os.path.abspath(python_executable)).as_posix()
|
|
109
|
+
with shim_path.open("w", encoding="utf-8", newline="\n") as handle:
|
|
110
|
+
handle.write("#!/bin/sh\n")
|
|
111
|
+
handle.write(f'exec "{python_executable}" "$@"\n')
|
|
112
|
+
shim_path.chmod(0o755)
|
|
113
|
+
return shim_path
|
|
114
|
+
|
|
115
|
+
def run(self):
|
|
116
|
+
self.build_meson_modules()
|
|
117
|
+
super().run()
|
|
118
|
+
self.prune_installed_import_libraries()
|
|
119
|
+
|
|
120
|
+
def prune_installed_import_libraries(self):
|
|
121
|
+
if self.inplace or not getattr(self, "build_lib", None):
|
|
122
|
+
return
|
|
123
|
+
build_lib_path = Path(self.build_lib)
|
|
124
|
+
if not build_lib_path.exists():
|
|
125
|
+
return
|
|
126
|
+
for import_lib in build_lib_path.rglob("*.dll.a"):
|
|
127
|
+
import_lib.unlink()
|
|
128
|
+
|
|
129
|
+
def _discover_meson_modules(self):
|
|
130
|
+
pkg_root = Path("src") / "skybornbackend"
|
|
131
|
+
modules = []
|
|
132
|
+
for meson_file in sorted(pkg_root.rglob("meson.build")):
|
|
133
|
+
rel_dir = meson_file.parent.relative_to(pkg_root)
|
|
134
|
+
name = ".".join(rel_dir.parts)
|
|
135
|
+
modules.append({"name": name, "path": meson_file.parent})
|
|
136
|
+
return modules
|
|
137
|
+
|
|
138
|
+
def should_build_meson_module(self, module, only_filter: set[str] | None = None):
|
|
139
|
+
if not (module["path"] / "meson.build").exists():
|
|
140
|
+
return False
|
|
141
|
+
if only_filter is not None and module["name"] not in only_filter:
|
|
142
|
+
return False
|
|
143
|
+
env_flag = OPTIONAL_MESON_MODULE_FLAGS.get(module["name"])
|
|
144
|
+
if env_flag and not _env_flag_enabled(env_flag):
|
|
145
|
+
return False
|
|
146
|
+
return True
|
|
147
|
+
|
|
148
|
+
def build_meson_modules(self):
|
|
149
|
+
only_filter = _parse_build_only_filter()
|
|
150
|
+
for module in self._discover_meson_modules():
|
|
151
|
+
if self.should_build_meson_module(module, only_filter=only_filter):
|
|
152
|
+
self.build_meson_module(module)
|
|
153
|
+
|
|
154
|
+
def _prepare_meson_env(self, build_dir: Path) -> dict[str, str]:
|
|
155
|
+
env = os.environ.copy()
|
|
156
|
+
active_prefix = _active_python_prefix()
|
|
157
|
+
conda_prefix = str(active_prefix) if active_prefix.exists() else ""
|
|
158
|
+
build_dir_path = str(build_dir.resolve())
|
|
159
|
+
system = platform.system()
|
|
160
|
+
|
|
161
|
+
if conda_prefix:
|
|
162
|
+
env["CONDA_PREFIX"] = conda_prefix
|
|
163
|
+
current_path = env.get("PATH", "")
|
|
164
|
+
if system == "Windows":
|
|
165
|
+
path_entries = [
|
|
166
|
+
build_dir_path,
|
|
167
|
+
conda_prefix,
|
|
168
|
+
os.path.join(conda_prefix, "Scripts"),
|
|
169
|
+
os.path.join(conda_prefix, "bin"),
|
|
170
|
+
os.path.join(conda_prefix, "Library", "bin"),
|
|
171
|
+
os.path.join(conda_prefix, "Library", "mingw-w64", "bin"),
|
|
172
|
+
os.path.join(conda_prefix, "Library", "usr", "bin"),
|
|
173
|
+
]
|
|
174
|
+
path_entries = [entry for entry in path_entries if os.path.isdir(entry)]
|
|
175
|
+
env["PATH"] = ";".join(path_entries + [current_path])
|
|
176
|
+
if CONDA_BUILD_MODE:
|
|
177
|
+
toolchain = {
|
|
178
|
+
"CC": "x86_64-w64-mingw32-gcc.exe",
|
|
179
|
+
"CXX": "x86_64-w64-mingw32-g++.exe",
|
|
180
|
+
"FC": "x86_64-w64-mingw32-gfortran.exe",
|
|
181
|
+
"F77": "x86_64-w64-mingw32-gfortran.exe",
|
|
182
|
+
"F90": "x86_64-w64-mingw32-gfortran.exe",
|
|
183
|
+
"AR": "x86_64-w64-mingw32-ar.exe",
|
|
184
|
+
"RANLIB": "x86_64-w64-mingw32-ranlib.exe",
|
|
185
|
+
}
|
|
186
|
+
for key, exe in toolchain.items():
|
|
187
|
+
found = shutil.which(exe, path=env["PATH"])
|
|
188
|
+
if found:
|
|
189
|
+
env[key] = found
|
|
190
|
+
elif system in ("Linux", "Darwin"):
|
|
191
|
+
conda_bin = os.path.join(conda_prefix, "bin")
|
|
192
|
+
path_entries = [build_dir_path]
|
|
193
|
+
if os.path.isdir(conda_bin):
|
|
194
|
+
path_entries.append(conda_bin)
|
|
195
|
+
env["PATH"] = ":".join(path_entries + [current_path])
|
|
196
|
+
if system == "Linux" and (
|
|
197
|
+
CONDA_BUILD_MODE or os.path.exists(os.path.join(conda_bin, "gfortran"))
|
|
198
|
+
):
|
|
199
|
+
conda_lib = os.path.join(conda_prefix, "lib")
|
|
200
|
+
cur_lib = env.get("LD_LIBRARY_PATH", "")
|
|
201
|
+
env["LD_LIBRARY_PATH"] = (
|
|
202
|
+
f"{conda_lib}:{cur_lib}" if cur_lib else conda_lib
|
|
203
|
+
)
|
|
204
|
+
if CONDA_BUILD_MODE and system == "Darwin":
|
|
205
|
+
for key in (
|
|
206
|
+
"AR",
|
|
207
|
+
"RANLIB",
|
|
208
|
+
"GCC_AR",
|
|
209
|
+
"GCC_RANLIB",
|
|
210
|
+
"LD",
|
|
211
|
+
"LDSHARED",
|
|
212
|
+
"CC_LD",
|
|
213
|
+
"CXX_LD",
|
|
214
|
+
"FC_LD",
|
|
215
|
+
"F77_LD",
|
|
216
|
+
"F90_LD",
|
|
217
|
+
):
|
|
218
|
+
env.pop(key, None)
|
|
219
|
+
ar_path = shutil.which("llvm-ar", path=conda_bin) or shutil.which(
|
|
220
|
+
"ar", path="/usr/bin"
|
|
221
|
+
)
|
|
222
|
+
ranlib_path = shutil.which(
|
|
223
|
+
"llvm-ranlib", path=conda_bin
|
|
224
|
+
) or shutil.which("ranlib", path="/usr/bin")
|
|
225
|
+
if ar_path or ranlib_path:
|
|
226
|
+
shim_dir = tempfile.mkdtemp(prefix="skybornbackend-tools-")
|
|
227
|
+
for nm in ("ar", "gcc-ar", "gar"):
|
|
228
|
+
if ar_path:
|
|
229
|
+
p = os.path.join(shim_dir, nm)
|
|
230
|
+
with open(p, "w", encoding="utf-8") as h:
|
|
231
|
+
h.write(
|
|
232
|
+
'#!/bin/sh\nif [ "x$1" = "x--version" ]; then echo "GNU ar (shim)"; exit 0; fi\n'
|
|
233
|
+
f'exec "{ar_path}" "$@"\n'
|
|
234
|
+
)
|
|
235
|
+
os.chmod(p, 0o755)
|
|
236
|
+
for nm in ("ranlib", "gcc-ranlib"):
|
|
237
|
+
if ranlib_path:
|
|
238
|
+
p = os.path.join(shim_dir, nm)
|
|
239
|
+
with open(p, "w", encoding="utf-8") as h:
|
|
240
|
+
h.write(
|
|
241
|
+
'#!/bin/sh\nif [ "x$1" = "x--version" ]; then echo "GNU ranlib (shim)"; exit 0; fi\n'
|
|
242
|
+
f'exec "{ranlib_path}" "$@"\n'
|
|
243
|
+
)
|
|
244
|
+
os.chmod(p, 0o755)
|
|
245
|
+
env["PATH"] = f"{shim_dir}:{env['PATH']}"
|
|
246
|
+
else:
|
|
247
|
+
current_path = env.get("PATH", "")
|
|
248
|
+
path_sep = ";" if system == "Windows" else ":"
|
|
249
|
+
env["PATH"] = (
|
|
250
|
+
f"{build_dir_path}{path_sep}{current_path}"
|
|
251
|
+
if current_path
|
|
252
|
+
else build_dir_path
|
|
253
|
+
)
|
|
254
|
+
return env
|
|
255
|
+
|
|
256
|
+
def build_meson_module(self, module):
|
|
257
|
+
module_path = module["path"]
|
|
258
|
+
build_dir = module_path / "build"
|
|
259
|
+
clean_requested = os.environ.get("SKYBORN_CLEAN_BUILD") == "1"
|
|
260
|
+
can_reuse = (
|
|
261
|
+
bool(self.inplace)
|
|
262
|
+
and not clean_requested
|
|
263
|
+
and (build_dir / "build.ninja").exists()
|
|
264
|
+
)
|
|
265
|
+
env = self._prepare_meson_env(build_dir)
|
|
266
|
+
|
|
267
|
+
if not can_reuse:
|
|
268
|
+
if build_dir.exists():
|
|
269
|
+
shutil.rmtree(build_dir)
|
|
270
|
+
build_dir.mkdir(parents=True, exist_ok=True)
|
|
271
|
+
native_file = self._write_meson_native_file(build_dir)
|
|
272
|
+
self._write_build_python_shim(build_dir)
|
|
273
|
+
|
|
274
|
+
setup_cmd = self._meson_command(
|
|
275
|
+
"setup",
|
|
276
|
+
"build",
|
|
277
|
+
".",
|
|
278
|
+
"--buildtype=release",
|
|
279
|
+
"--native-file",
|
|
280
|
+
str(native_file),
|
|
281
|
+
)
|
|
282
|
+
setup_cmd.append(
|
|
283
|
+
"-Db_lto=false" if (CONDA_BUILD_MODE or not self.inplace) else "-Db_lto=true"
|
|
284
|
+
)
|
|
285
|
+
if not self.inplace and getattr(self, "build_lib", None):
|
|
286
|
+
build_lib_path = Path(self.build_lib).resolve()
|
|
287
|
+
setup_cmd.extend(
|
|
288
|
+
[
|
|
289
|
+
f"--python.purelibdir={build_lib_path}",
|
|
290
|
+
f"--python.platlibdir={build_lib_path}",
|
|
291
|
+
]
|
|
292
|
+
)
|
|
293
|
+
subprocess.run(setup_cmd, cwd=str(module_path), check=True, env=env)
|
|
294
|
+
|
|
295
|
+
subprocess.run(
|
|
296
|
+
self._meson_command("compile", "-C", "build"),
|
|
297
|
+
cwd=str(module_path),
|
|
298
|
+
check=True,
|
|
299
|
+
env=env,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
if not self.inplace and getattr(self, "build_lib", None):
|
|
303
|
+
subprocess.run(
|
|
304
|
+
self._meson_command("install", "-C", "build", "--only-changed"),
|
|
305
|
+
cwd=str(module_path),
|
|
306
|
+
check=True,
|
|
307
|
+
env=env,
|
|
308
|
+
)
|
|
309
|
+
self.prune_installed_import_libraries()
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
class CustomDevelop(develop):
|
|
313
|
+
def run(self):
|
|
314
|
+
self.run_command("build_ext")
|
|
315
|
+
super().run()
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class CustomInstall(install):
|
|
319
|
+
def run(self):
|
|
320
|
+
self.run_command("build_ext")
|
|
321
|
+
super().run()
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class CustomInstallLib(install_lib):
|
|
325
|
+
"""Prune transient build artifacts and bytecode from installed package trees."""
|
|
326
|
+
|
|
327
|
+
_PRUNE_DIR_NAMES = {
|
|
328
|
+
"__pycache__",
|
|
329
|
+
"build",
|
|
330
|
+
"build_local",
|
|
331
|
+
"meson-private",
|
|
332
|
+
"meson-logs",
|
|
333
|
+
"meson-info",
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
def run(self):
|
|
337
|
+
super().run()
|
|
338
|
+
package_root = Path(self.install_dir) / "skybornbackend"
|
|
339
|
+
if not package_root.exists():
|
|
340
|
+
return
|
|
341
|
+
for path in sorted(
|
|
342
|
+
package_root.rglob("*"), key=lambda item: len(item.parts), reverse=True
|
|
343
|
+
):
|
|
344
|
+
if path.is_dir() and (
|
|
345
|
+
path.name in self._PRUNE_DIR_NAMES or path.name.startswith("build_")
|
|
346
|
+
):
|
|
347
|
+
shutil.rmtree(path, ignore_errors=True)
|
|
348
|
+
elif path.is_file() and path.suffix.lower() in {".pyc", ".pyo"}:
|
|
349
|
+
path.unlink()
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class BinaryDistribution(Distribution):
|
|
353
|
+
def has_ext_modules(self):
|
|
354
|
+
return True
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class CustomBdistWheel(bdist_wheel):
|
|
358
|
+
def finalize_options(self):
|
|
359
|
+
super().finalize_options()
|
|
360
|
+
self.root_is_pure = False
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
if __name__ == "__main__":
|
|
364
|
+
setup(
|
|
365
|
+
cmdclass={
|
|
366
|
+
"bdist_wheel": CustomBdistWheel,
|
|
367
|
+
"build_ext": MesonBuildExt,
|
|
368
|
+
"develop": CustomDevelop,
|
|
369
|
+
"install": CustomInstall,
|
|
370
|
+
"install_lib": CustomInstallLib,
|
|
371
|
+
},
|
|
372
|
+
distclass=BinaryDistribution,
|
|
373
|
+
ext_modules=[],
|
|
374
|
+
)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: skyborn-backend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compiled Fortran, C, and Cython computational kernels for Skyborn
|
|
5
|
+
Author-email: Qianye Su <suqianye2000@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/skyborn-org/skyborn-backend
|
|
8
|
+
Project-URL: Repository, https://github.com/skyborn-org/skyborn-backend
|
|
9
|
+
Project-URL: Documentation, https://skyborn.readthedocs.io/
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/skyborn-org/skyborn-backend/issues
|
|
11
|
+
Keywords: atmospheric-science,meteorology,climate,fortran,kernels
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Operating System :: MacOS
|
|
24
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
25
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# skyborn-backend (`skybornbackend`)
|
|
35
|
+
|
|
36
|
+
Prebuilt Fortran, C, and Cython numerical computation kernels powering the [**Skyborn**](https://github.com/skyborn-org/Skyborn) atmospheric and climate science ecosystem.
|
|
37
|
+
|
|
38
|
+
Part of the [**Skyborn** (`skyborn-org`)](https://github.com/skyborn-org) organization.
|
|
39
|
+
|
|
40
|
+
## Included Compiled Modules
|
|
41
|
+
|
|
42
|
+
- `skybornbackend.gridfill`: Poisson spherical/rectangular gap-filling (`_gridfill`).
|
|
43
|
+
- `skybornbackend.interp`: Vertical hybrid/pressure/isentropic interpolation, horizontal bilinear/conserving regridding, and curvilinear-to-rectilinear kernels.
|
|
44
|
+
- `skybornbackend.calc`:
|
|
45
|
+
- `GPI`: Potential intensity kernels (`tropical_cyclone_potential_intensity`)
|
|
46
|
+
- `cape` & `dcape`: Convective and downdraft CAPE kernels
|
|
47
|
+
- `causality`: Batch Liang–Kleeman information flow & AR(1) kernels
|
|
48
|
+
- `filter`: Lanczos filtering Fortran kernels
|
|
49
|
+
- `geostrophic`: Geostrophic wind solver (`geostrophicwind`)
|
|
50
|
+
- `growth_rate`: Eady baroclinic & barotropic growth rate kernels
|
|
51
|
+
- `mann_kendall`: Vectorized multidimensional Mann–Kendall & Theil–Sen kernels
|
|
52
|
+
- `srh`: Storm-relative helicity kernels
|
|
53
|
+
- `troposphere`: WMO tropopause height kernels
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Most users should install the high-level library instead, which pulls this package automatically:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install skyborn
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Developer Incremental Build Tips
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# First inplace build compiles all 12 Meson modules:
|
|
67
|
+
python setup.py build_ext --inplace
|
|
68
|
+
|
|
69
|
+
# Subsequent edits reuse Ninja caches; optionally target a single module:
|
|
70
|
+
SKYBORN_BUILD_ONLY=calc.mann_kendall python setup.py build_ext --inplace
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
BSD 3-Clause License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/skyborn_backend.egg-info/PKG-INFO
|
|
6
|
+
src/skyborn_backend.egg-info/SOURCES.txt
|
|
7
|
+
src/skyborn_backend.egg-info/dependency_links.txt
|
|
8
|
+
src/skyborn_backend.egg-info/requires.txt
|
|
9
|
+
src/skyborn_backend.egg-info/top_level.txt
|
|
10
|
+
src/skybornbackend/__init__.py
|
|
11
|
+
src/skybornbackend/calc/__init__.py
|
|
12
|
+
src/skybornbackend/calc/GPI/__init__.py
|
|
13
|
+
src/skybornbackend/calc/cape/__init__.py
|
|
14
|
+
src/skybornbackend/calc/causality/__init__.py
|
|
15
|
+
src/skybornbackend/calc/dcape/__init__.py
|
|
16
|
+
src/skybornbackend/calc/filter/__init__.py
|
|
17
|
+
src/skybornbackend/calc/geostrophic/__init__.py
|
|
18
|
+
src/skybornbackend/calc/growth_rate/__init__.py
|
|
19
|
+
src/skybornbackend/calc/mann_kendall/__init__.py
|
|
20
|
+
src/skybornbackend/calc/srh/__init__.py
|
|
21
|
+
src/skybornbackend/calc/troposphere/__init__.py
|
|
22
|
+
src/skybornbackend/gridfill/__init__.py
|
|
23
|
+
src/skybornbackend/interp/__init__.py
|
|
24
|
+
tests/test_backend_imports.py
|
|
25
|
+
tests/test_setup_build_tools.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
skybornbackend
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.GPI."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled atmospheric calculation kernels."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.cape."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.causality."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.dcape."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.filter."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.geostrophic."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.growth_rate."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.mann_kendall."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.srh."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled kernels for skyborn.calc.troposphere."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled Poisson grid-filling kernel."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compiled interpolation and regridding kernels."""
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Tests verifying compiled extension imports and selective build utilities in skybornbackend."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_version_present():
|
|
11
|
+
import skybornbackend
|
|
12
|
+
|
|
13
|
+
assert skybornbackend.__version__ == "0.1.0"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_all_compiled_backend_extensions_importable():
|
|
17
|
+
extension_modules = [
|
|
18
|
+
"skybornbackend.gridfill._gridfill",
|
|
19
|
+
"skybornbackend.interp.regrid",
|
|
20
|
+
"skybornbackend.interp.fortran.grid2triple",
|
|
21
|
+
"skybornbackend.interp.fortran.int2p_kernels",
|
|
22
|
+
"skybornbackend.interp.fortran.isentropic_kernels",
|
|
23
|
+
"skybornbackend.interp.fortran.rcm2points",
|
|
24
|
+
"skybornbackend.interp.fortran.rcm2rgrid",
|
|
25
|
+
"skybornbackend.interp.fortran.triple2grid",
|
|
26
|
+
"skybornbackend.interp.fortran.vinth2p_kernels",
|
|
27
|
+
"skybornbackend.calc.GPI.tropical_cyclone_potential_intensity",
|
|
28
|
+
"skybornbackend.calc.cape.cape_core",
|
|
29
|
+
"skybornbackend.calc.causality._causality_core",
|
|
30
|
+
"skybornbackend.calc.dcape.dcape_core",
|
|
31
|
+
"skybornbackend.calc.filter._lanczos_core",
|
|
32
|
+
"skybornbackend.calc.geostrophic.geostrophicwind",
|
|
33
|
+
"skybornbackend.calc.growth_rate.growth_rate_kernels",
|
|
34
|
+
"skybornbackend.calc.mann_kendall.mann_kendall_core",
|
|
35
|
+
"skybornbackend.calc.srh.srh_core",
|
|
36
|
+
"skybornbackend.calc.troposphere.tropopause_height",
|
|
37
|
+
]
|
|
38
|
+
for mod_name in extension_modules:
|
|
39
|
+
mod = importlib.import_module(mod_name)
|
|
40
|
+
assert mod is not None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_mann_kendall_kernel_smoke():
|
|
44
|
+
from skybornbackend.calc.mann_kendall.mann_kendall_core import mk_score_var_batch
|
|
45
|
+
|
|
46
|
+
series = np.asfortranarray(np.arange(1, 11, dtype=np.float64)[:, None])
|
|
47
|
+
s_vals, var_vals = mk_score_var_batch(series, 0)
|
|
48
|
+
assert float(s_vals[0]) == 45.0
|
|
49
|
+
assert float(var_vals[0]) > 0.0
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Regression tests for build-tool command resolution."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib.util
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _load_setup_module():
|
|
10
|
+
setup_path = Path(__file__).resolve().parents[1] / "setup.py"
|
|
11
|
+
spec = importlib.util.spec_from_file_location("skyborn_setup", setup_path)
|
|
12
|
+
if spec is None or spec.loader is None:
|
|
13
|
+
raise RuntimeError("Unable to load setup.py for testing")
|
|
14
|
+
|
|
15
|
+
module = importlib.util.module_from_spec(spec)
|
|
16
|
+
spec.loader.exec_module(module)
|
|
17
|
+
return module
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_ninja_command_prefers_executable_when_available(monkeypatch):
|
|
21
|
+
setup_module = _load_setup_module()
|
|
22
|
+
monkeypatch.setattr(setup_module.shutil, "which", lambda name: "/opt/bin/ninja")
|
|
23
|
+
|
|
24
|
+
assert setup_module.MesonBuildExt._ninja_command("--version") == [
|
|
25
|
+
"/opt/bin/ninja",
|
|
26
|
+
"--version",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_ninja_command_falls_back_to_python_module_when_needed(monkeypatch):
|
|
31
|
+
setup_module = _load_setup_module()
|
|
32
|
+
monkeypatch.setattr(setup_module.shutil, "which", lambda name: None)
|
|
33
|
+
monkeypatch.setattr(setup_module.sys, "executable", "/opt/conda/bin/python")
|
|
34
|
+
|
|
35
|
+
assert setup_module.MesonBuildExt._ninja_command("--version") == [
|
|
36
|
+
"/opt/conda/bin/python",
|
|
37
|
+
"-m",
|
|
38
|
+
"ninja",
|
|
39
|
+
"--version",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_meson_command_prefers_executable_when_available(monkeypatch):
|
|
44
|
+
setup_module = _load_setup_module()
|
|
45
|
+
monkeypatch.setattr(setup_module.shutil, "which", lambda name: "/opt/bin/meson")
|
|
46
|
+
|
|
47
|
+
assert setup_module.MesonBuildExt._meson_command("--version") == [
|
|
48
|
+
"/opt/bin/meson",
|
|
49
|
+
"--version",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_meson_command_falls_back_to_python_module_when_needed(monkeypatch):
|
|
54
|
+
setup_module = _load_setup_module()
|
|
55
|
+
monkeypatch.setattr(setup_module.shutil, "which", lambda name: None)
|
|
56
|
+
monkeypatch.setattr(setup_module.sys, "executable", "/opt/conda/bin/python")
|
|
57
|
+
|
|
58
|
+
assert setup_module.MesonBuildExt._meson_command("--version") == [
|
|
59
|
+
"/opt/conda/bin/python",
|
|
60
|
+
"-m",
|
|
61
|
+
"mesonbuild.mesonmain",
|
|
62
|
+
"--version",
|
|
63
|
+
]
|