Skip to content

Commit 00c4789

Browse files
Merge pull request #675 from cal-adapt/improve/migrate-to-pyproject-toml
Improve/migrate to pyproject toml
2 parents 0a74bf7 + d7f2ca5 commit 00c4789

20 files changed

Lines changed: 703 additions & 617 deletions

.github/workflows/ci-main.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
name: ci-main
77

8-
on:
8+
on:
99
push:
1010
branches:
1111
- main
@@ -17,29 +17,39 @@ jobs:
1717
- uses: actions/checkout@v3
1818
- uses: psf/black@stable
1919
test:
20-
name: test
20+
name: test (Python ${{ matrix.python-version }})
2121
runs-on: ubuntu-latest
22+
timeout-minutes: 45
23+
strategy:
24+
matrix:
25+
python-version: ["3.12", "3.13"]
26+
fail-fast: false
2227
defaults:
2328
run:
2429
shell: bash -l {0}
2530
steps:
26-
- name: Checkout project
27-
uses: actions/checkout@v4
28-
- name: Setup Python 3.12
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: '3.12'
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install -r requirements.txt
36-
pip install pytest cftime pytest-cov pytest-xdist
37-
- name: Install climakitae
38-
run: pip install . --no-deps
39-
- name: Test with pytest
40-
run: pytest -n auto --no-header -vv --cov --cov-branch --cov-report=xml
41-
- name: Upload coverage reports to Codecov
42-
uses: codecov/codecov-action@v5
43-
with:
44-
token: ${{ secrets.CODECOV_TOKEN }}
45-
slug: cal-adapt/climakitae
31+
- name: Checkout project
32+
uses: actions/checkout@v4
33+
- name: Setup Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Install uv
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install uv
41+
- name: Create uv virtual environment
42+
run: uv venv --python ${{ matrix.python-version }}
43+
- name: Install dependencies
44+
run: uv pip install -e ".[dev]"
45+
- name: Verify installation
46+
run: |
47+
uv run python --version
48+
uv run python -c "import climakitae; print(f'climakitae version: {climakitae.__version__}')"
49+
- name: Test with pytest
50+
run: uv run python -m pytest --no-header -vv --cov --cov-branch --cov-report=xml
51+
- name: Upload coverage reports to Codecov
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
slug: cal-adapt/climakitae

.github/workflows/ci-not-main.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
# Runs on all branches except main (see ci-main.yml)
55
# Runs basic tests on push event and advanced tests on label assignment
66

7-
87
name: ci-not-main
98

10-
on:
9+
on:
1110
push:
1211
branches-ignore:
1312
- main
@@ -22,27 +21,37 @@ jobs:
2221
- uses: actions/checkout@v3
2322
- uses: psf/black@stable
2423
test:
25-
name: test
24+
name: test (Python ${{ matrix.python-version }})
2625
runs-on: ubuntu-latest
26+
timeout-minutes: 30
27+
strategy:
28+
matrix:
29+
python-version: ["3.12", "3.13"]
30+
fail-fast: false
2731
defaults:
2832
run:
2933
shell: bash -l {0}
3034
steps:
31-
- name: Checkout project
32-
uses: actions/checkout@v4
33-
- name: Setup Python 3.12
34-
uses: actions/setup-python@v5
35-
with:
36-
python-version: '3.12'
37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip
40-
pip install -r requirements.txt
41-
pip install pytest cftime pytest-xdist
42-
- name: Install climakitae
43-
run: pip install . --no-deps
44-
- name: Test with pytest (Basic)
45-
run: pytest -n auto --no-header -vv -m "not advanced"
46-
- name: Test with pytest (Advanced)
47-
if: github.event.label.name == 'Advanced Testing'
48-
run: pytest -n auto --no-header -vv -m "advanced"
35+
- name: Checkout project
36+
uses: actions/checkout@v4
37+
- name: Setup Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Install uv
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install uv
45+
- name: Create uv virtual environment
46+
run: uv venv --python ${{ matrix.python-version }}
47+
- name: Install dependencies
48+
run: uv pip install -e ".[dev]"
49+
- name: Verify installation
50+
run: |
51+
uv run python --version
52+
uv run python -c "import climakitae; print(f'climakitae version: {climakitae.__version__}')"
53+
- name: Test with pytest (Basic)
54+
run: uv run python -m pytest --no-header -vv -m "not advanced"
55+
- name: Test with pytest (Advanced)
56+
if: github.event.label.name == 'Advanced Testing'
57+
run: uv run python -m pytest --no-header -vv -m "advanced"

.github/workflows/publish.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Allows manual trigger
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Need full history for setuptools_scm
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install pytest
28+
pip install -e .
29+
30+
- name: Run basic tests
31+
run: pytest -m "not advanced" || echo "Tests failed but continuing"
32+
# Remove '|| echo...' once you want tests to block releases
33+
34+
build:
35+
needs: test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # setuptools_scm needs git history
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
46+
47+
- name: Install build tools
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install build twine
51+
52+
- name: Build package
53+
run: python -m build
54+
55+
- name: Check package
56+
run: twine check dist/*
57+
58+
- name: List built files
59+
run: ls -lh dist/
60+
61+
- name: Upload build artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: dist
65+
path: dist/
66+
retention-days: 7
67+
68+
publish:
69+
needs: build
70+
runs-on: ubuntu-latest
71+
environment:
72+
name: pypi
73+
url: https://pypi.org/p/climakitae
74+
permissions:
75+
id-token: write # Required for trusted publishing
76+
77+
steps:
78+
- name: Download build artifacts
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: dist
82+
path: dist/
83+
84+
- name: Publish to PyPI (Trusted Publishing)
85+
uses: pypa/gh-action-pypi-publish@release/v1
86+
# If using API token instead, add:
87+
# with:
88+
# password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/vd_md.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ share/python-wheels/
2525
.installed.cfg
2626
*.egg
2727
MANIFEST
28+
**/_version.py
2829

2930
.github/instructions
3031

README.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,18 @@ Climakitae is developed as part of the [Cal-Adapt Analytics Engine](https://anal
3535

3636
#### Prerequisites
3737

38-
- Python 3.12
38+
- Python 3.12 | 3.13
3939
- [conda / miniconda](https://www.anaconda.com/docs/getting-started/miniconda/install#quickstart-install-instructions)
4040

41-
#### Install 1.4.0 with `conda` on Linux
41+
#### Install latest release with `conda` on Linux
4242

4343
For additional details on the latest version and step-by-step installation instructions please visit [the wiki](https://github.com/cal-adapt/climakitae/wiki)
4444

4545
```bash
46-
# get the conda lock file from github
47-
curl https://raw.githubusercontent.com/cal-adapt/cae-environments/refs/heads/main/conda-lock/climakitae/1.3.0/conda-linux-64.lock -o conda-linux-64.lock
48-
49-
# create and activate your environment
50-
conda create -n climakitae --file conda-linux-64.lock
46+
# create a conda environment with
47+
conda create -n climakitae python=3.13 -y
5148
conda activate climakitae
52-
53-
# install climakitae
54-
pip install https://github.com/cal-adapt/climakitae/archive/refs/tags/1.4.0.zip
49+
pip install climakitae
5550
```
5651

5752
### Installation via Pip
@@ -61,19 +56,13 @@ pip install https://github.com/cal-adapt/climakitae/archive/refs/tags/1.4.0.zip
6156
- Python 3.12
6257
- pip
6358

64-
#### Install 1.3.0 with `pip` on Linux
59+
#### Install latest release with `pip` on Linux
6560

6661
For additional details on the latest version and step-by-step installation instructions please visit [the wiki](https://github.com/cal-adapt/climakitae/wiki)
6762

6863
```bash
69-
# get the requirements.txt file from github
70-
curl https://raw.githubusercontent.com/cal-adapt/climakitae/refs/heads/release-1.3.0/requirements.txt -o requirements.txt
71-
72-
# load packages from requirements.txt
73-
pip install -r requirements.txt
74-
75-
# install climakitae
76-
pip install https://github.com/cal-adapt/climakitae/archive/refs/tags/1.4.0.zip
64+
pip install --upgrade pip
65+
pip install climakitae
7766
```
7867

7968
### Basic Usage

climakitae/__init__.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
from climakitae.core.data_export import export, remove_zarr
22
from climakitae.core.data_load import load
3-
4-
try:
5-
from importlib.metadata import version as _version
6-
except ImportError:
7-
# if the fallback library is missing, we are doomed.
8-
from importlib_metadata import version as _version # type: ignore[no-redef]
9-
10-
try:
11-
__version__ = _version("climakitae")
12-
except Exception:
13-
# Local copy or not installed with setuptools.
14-
# Disable minimum version checks on downstream libraries.
15-
__version__ = "999"
3+
from climakitae._version import __version__
4+
from climakitae.new_core.user_interface import ClimateData
165

176
__all__ = (
187
# Methods
198
"load",
209
"export",
2110
"remove_zarr",
11+
# Classes
12+
"ClimateData",
2213
# Constants
2314
"__version__",
2415
)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
copyright = "2025, Cal-Adapt Analytics Engine"
1919
author = "Cal-Adapt Analytics Engine Team"
2020
# The full version, including alpha/beta/rc tags
21-
release = "1.4.0"
21+
release = "1.4.1"
2222

2323
# -- General configuration ---------------------------------------------------
2424
# Add any Sphinx extension module names here, as strings. They can be

0 commit comments

Comments
 (0)