Skip to content

Commit 9b8c9ab

Browse files
authored
Update Python support (#735)
* Update Python support * Match latest zstash python support * Fixes try 2 * Further updates * Address comments * Address further comments
1 parent 0aa91a6 commit 9b8c9ab

File tree

7 files changed

+56
-40
lines changed

7 files changed

+56
-40
lines changed

.github/workflows/build_workflow.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,26 @@ jobs:
3737
- name: Checkout Code Repository
3838
uses: actions/checkout@v3
3939

40-
- name: Set up Python
40+
- name: Set up Python 3.13
4141
uses: actions/setup-python@v4
4242
with:
43-
python-version: 3.9
43+
python-version: 3.13
4444

4545
# Run all pre-commit hooks on all the files.
4646
# Getting only staged files can be tricky in case a new PR is opened
4747
# since the action is run on a branch in detached head state.
4848
# This is the equivalent of running "pre-commit run --all-files" locally.
4949
# If you commit with the `--no-verify` flag, this check may fail.
5050
- name: Install and Run Pre-commit
51-
uses: pre-commit/[email protected].0
51+
uses: pre-commit/[email protected].1
5252

5353
build:
5454
needs: check-jobs-to-skip
5555
if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }}
5656
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
python-version: ["3.11", "3.12", "3.13"]
5760
defaults:
5861
run:
5962
shell: bash -l {0}
@@ -63,11 +66,11 @@ jobs:
6366
- name: Cache Conda
6467
uses: actions/cache@v3
6568
env:
66-
CACHE_NUMBER: 0
69+
CACHE_NUMBER: 1 # Increment this to invalidate cache
6770
with:
6871
path: ~/conda_pkgs_dir
6972
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
70-
hashFiles('conda/dev.yml') }}
73+
hashFiles('conda/dev.yml') }}-python${{ matrix.python-version }}
7174

7275
- name: Build Conda Environment
7376
uses: conda-incubator/setup-miniconda@v3
@@ -76,8 +79,23 @@ jobs:
7679
miniforge-variant: Miniforge3
7780
miniforge-version: latest
7881
environment-file: conda/dev.yml
79-
channel-priority: strict
82+
channel-priority: flexible # Changed from strict to flexible
8083
auto-update-conda: true
84+
python-version: ${{ matrix.python-version }}
85+
channels: conda-forge
86+
use-only-tar-bz2: true
87+
88+
- name: Verify Environment and Fix Dependencies
89+
run: |
90+
conda info
91+
conda list
92+
# Ensure we have the right Python version
93+
python --version
94+
# Fix pip issues for Python 3.12+
95+
if [[ "${{ matrix.python-version }}" == "3.12" ]] || [[ "${{ matrix.python-version }}" == "3.13" ]]; then
96+
python -m ensurepip --upgrade || true
97+
python -m pip install --upgrade --force-reinstall pip setuptools wheel
98+
fi
8199
82100
- if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }}
83101
name: Show Conda Environment Info
@@ -87,7 +105,7 @@ jobs:
87105
conda list
88106
89107
- name: Install `zppy` Package
90-
run: pip install .
108+
run: python -m pip install .
91109

92110
# Does not run the integration tests, which require server access
93111
- name: Run Unit Tests
@@ -101,7 +119,7 @@ jobs:
101119
defaults:
102120
run:
103121
shell: bash -l {0}
104-
timeout-minutes: 5
122+
timeout-minutes: 10 # Increased timeout for docs
105123
steps:
106124
- uses: actions/checkout@v2
107125
with:
@@ -111,11 +129,11 @@ jobs:
111129
- name: Cache Conda
112130
uses: actions/cache@v3
113131
env:
114-
CACHE_NUMBER: 0
132+
CACHE_NUMBER: 1 # Match the build job cache number
115133
with:
116134
path: ~/conda_pkgs_dir
117135
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
118-
hashFiles('conda/dev.yml') }}
136+
hashFiles('conda/dev.yml') }}-docs
119137

120138
- name: Build Conda Environment
121139
uses: conda-incubator/setup-miniconda@v3
@@ -124,8 +142,9 @@ jobs:
124142
miniforge-variant: Miniforge3
125143
miniforge-version: latest
126144
environment-file: conda/dev.yml
127-
channel-priority: strict
145+
channel-priority: flexible # Changed from strict to flexible
128146
auto-update-conda: true
147+
python-version: "3.13" # Use stable Python version for docs
129148

130149
- if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }}
131150
name: Show Conda Environment Info

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ repos:
1313

1414
# Can run individually with `pre-commit run black --all-files`
1515
- repo: https://github.com/psf/black
16-
rev: 24.10.0
16+
rev: 25.1.0
1717
hooks:
1818
- id: black
1919

2020
# Can run individually with `pre-commit run isort --all-files`
2121
- repo: https://github.com/PyCQA/isort
22-
rev: 5.13.2
22+
rev: 6.0.1
2323
hooks:
2424
- id: isort
2525

2626
# Can run individually with `pre-commit run flake8 --all-files`
2727
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
2828
# https://github.com/pre-commit/pre-commit/issues/1206
2929
- repo: https://github.com/pycqa/flake8
30-
rev: 7.1.1
30+
rev: 7.3.0
3131
hooks:
3232
- id: flake8
3333
args: ["--config=setup.cfg"]
3434
additional_dependencies: [flake8-isort==6.1.1]
3535

3636
# Can run individually with `pre-commit run mypy --all-files`
3737
- repo: https://github.com/pre-commit/mirrors-mypy
38-
rev: v1.11.2
38+
rev: v1.18.2
3939
hooks:
4040
- id: mypy
4141
args: ["--config=setup.cfg"]

conda/dev.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,43 @@
77
name: zppy_dev
88
channels:
99
- conda-forge
10-
- defaults
1110
dependencies:
1211
# Build
1312
# =======================
14-
- python=3.9.13
15-
- pip=22.2.2
13+
- python >=3.11,<3.14
14+
- pip
1615
# Base
1716
# =================
18-
- configobj=5.0.6
19-
- jinja2=3.1.2
17+
- configobj>=5.0.6 # Changed from =5.0.6
18+
- jinja2>=3.1.2 # Changed from =3.1.2
2019
- mache>=1.5.0
2120
- mpas_tools>=0.15.0
22-
- pillow=9.2.0
21+
- pillow>=9.2.0 # Changed from =9.2.0
2322
# Testing
2423
# =======================
2524
- pytest
2625
- pytest-cov
2726
# Documentation
2827
# If versions are updated, also update in `.github/workflows/build_workflow.yml`
2928
# =================
30-
- sphinx=5.2.3
31-
- sphinx_rtd_theme=1.0.0
32-
- sphinx-multiversion=0.2.4
29+
- sphinx >=5.2.0
30+
- sphinx-multiversion >=0.2.4
31+
- sphinx_rtd_theme >=1.0.0
3332
# Need to pin docutils because 0.17 has a bug with unordered lists
3433
# https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
35-
- docutils=0.16
34+
# This issue has been resolved.
35+
- docutils>=0.16 # Removed <0.17 constraint
3636
# Quality Assurance Tools
3737
# =======================
3838
# If versions are updated, also update 'rev' in `.pre-commit-config.yaml`
39-
- black=24.10.0 # version from https://anaconda.org/conda-forge/black
40-
- flake8=7.1.1 # version from https://anaconda.org/conda-forge/flake8
41-
# This line also implicitly installs isort
42-
- flake8-isort=6.1.1 # version from https://anaconda.org/conda-forge/flake8-isort
43-
- mypy=1.11.2 # version from https://anaconda.org/conda-forge/mypy
44-
- pre-commit=4.0.1 # version from https://anaconda.org/conda-forge/pre-commit
45-
- tbump=6.9.0
39+
- black ==25.1.0
40+
- flake8 ==7.3.0
41+
- isort ==6.0.1
42+
- mypy ==1.18.2
43+
- pre-commit ==4.3.0
44+
- tbump >=6.9.0
4645
# Developer Tools
4746
# =======================
48-
- tbump=6.9.0
4947
- ipykernel
5048

5149
prefix: /opt/miniconda3/envs/zppy_dev

conda/meta.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{% set name = "zppy" %}
22
{% set version = "3.0.0" %}
3-
{% set python_min = "3.9" %}
43

54
package:
65
name: {{ name|lower }}
@@ -17,19 +16,19 @@ build:
1716

1817
requirements:
1918
host:
20-
- python {{ python_min }}
19+
- python >=3.11,<3.14
2120
- pip
2221
- setuptools
2322
run:
24-
- python >={{ python_min }}
23+
- python >=3.11,<3.14
2524
- configobj >=5.0.0,<6.0.0
2625
- jinja2 >=2.0.0
2726
- mache >=1.3.2
2827
- mpas_tools >=0.15.0
2928

3029
test:
3130
requires:
32-
- python {{ python_min }}
31+
- python >=3.11,<3.14
3332
- pip
3433
imports:
3534
- zppy

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[tool.black]
66
line-length = 88
7-
target-version = ['py36']
7+
target-version = ['py311']
88
include = '\.pyi?$'
99
exclude = '''
1010
/(

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ exclude =
4848
venv
4949

5050
[mypy]
51-
python_version = 3.9
51+
python_version = 3.13
5252
check_untyped_defs = True
5353
ignore_missing_imports = True
5454
warn_unused_ignores = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def package_files(directory, prefixes, extensions):
2727
author="Ryan Forsyth, Chris Golaz",
2828
2929
description="Post-processing software for E3SM",
30-
python_requires=">=3.9",
30+
python_requires=">=3.11,<3.14",
3131
packages=find_packages(include=["zppy", "zppy.*"]),
3232
package_data={"": data_files},
3333
entry_points={"console_scripts": ["zppy=zppy.__main__:main"]},

0 commit comments

Comments
 (0)