Skip to content

Commit 8f46b30

Browse files
Simplify conda environments and move configs to pyproject.toml (#512)
1 parent 792cdbd commit 8f46b30

File tree

8 files changed

+77
-139
lines changed

8 files changed

+77
-139
lines changed

.github/workflows/build_workflow.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
shell: bash -l {0}
5151
strategy:
5252
matrix:
53-
python-version: ["3.8", "3.9", "3.10"]
53+
python-version: ["3.9", "3.10", "3.11"]
5454
steps:
5555
- id: skip_check
5656
uses: fkirc/skip-duplicate-actions@master
@@ -98,7 +98,10 @@ jobs:
9898

9999
- if: $${{ steps.skip_check.outputs.should_skip != 'true' || steps.cache.outputs.cache-hit != 'true' }}
100100
name: Update environment
101-
run: mamba env update -n xcdat_ci -f conda-env/ci.yml
101+
run: |
102+
mamba env update -n xcdat_ci -f conda-env/ci.yml
103+
# Make sure the Python version in the env matches the current matrix version.
104+
mamba install -c conda-forge python=${{ matrix.python-version }}
102105
103106
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
104107
name: Install xcdat

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: check-yaml
1212

1313
- repo: https://github.com/psf/black
14-
rev: 23.1.0
14+
rev: 23.3.0
1515
hooks:
1616
- id: black
1717

@@ -30,15 +30,15 @@ repos:
3030
additional_dependencies: [flake8-isort]
3131

3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v1.1.1
33+
rev: v1.4.0
3434
hooks:
3535
- id: mypy
36-
args: ["--config=setup.cfg"]
36+
args: ["--config=pyproject.toml"]
3737
additional_dependencies:
3838
[
39-
dask==2023.3.2,
40-
numpy==1.23.5,
41-
pandas==1.5.3,
42-
xarray==2023.3.0,
43-
types-python-dateutil==2.8.19,
39+
dask,
40+
numpy>=1.23.0,
41+
pandas,
42+
xarray>=2023.2.0,
43+
types-python-dateutil,
4444
]

.readthedocs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
version: 2
77

88
build:
9-
os: "ubuntu-20.04"
10-
tools:
11-
python: "mambaforge-4.10"
9+
os: "ubuntu-20.04"
10+
tools:
11+
python: "mambaforge-4.10"
1212

1313
# Build documentation in the docs/ directory with Sphinx
1414
sphinx:
@@ -19,4 +19,4 @@ formats:
1919
- pdf
2020

2121
conda:
22-
environment: conda-env/readthedocs.yml
22+
environment: conda-env/dev.yml

conda-env/ci.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
# Conda xcdat CI/CD environment (used in GH Actions)
1+
# Conda xcdat CI/CD environment (used in GH Actions).
22
name: xcdat_ci
33
channels:
44
- conda-forge
55
- defaults
66
dependencies:
7-
# ==================
8-
# Base
9-
# ==================
10-
- python >=3.8
11-
- pip
7+
# Base - required for building the package.
8+
# =========================================
9+
- python >=3.9
1210
- cf_xarray
1311
- cftime
1412
- dask
15-
- esmpy
1613
- lxml
1714
- netcdf4
18-
- numpy
15+
- numpy >=1.23.0 # This version of numpy includes support for Python 3.11.
1916
- pandas
2017
- python-dateutil
21-
- xarray
22-
# Constrained because 0.6.3 breaks with import ESMF
23-
# Source: https://github.com/pangeo-data/xESMF/issues/212
24-
- xesmf >0.6.3
18+
- xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9.
2519
- xgcm
20+
# Optional - enables additional features.
21+
# =========================================
22+
- xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212.
2623
# Quality Assurance
2724
# ==================
2825
- types-python-dateutil

conda-env/dev.yml

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@ channels:
44
- conda-forge
55
- defaults
66
dependencies:
7-
# ==================
8-
# Base
9-
# ==================
10-
# NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml`
11-
- python=3.10.10
12-
- pip=23.0.1
13-
- cf_xarray=0.8.0
14-
- cftime=1.6.2
15-
- dask=2023.3.2
16-
- lxml=4.9.2
17-
- netcdf4=1.6.3
18-
- numpy=1.23.5
19-
- pandas=1.5.3
20-
- python-dateutil=2.8.2
21-
- xarray=2023.4.2
22-
- xgcm=0.8.0
23-
# ==================
24-
# Optional
25-
# ==================
26-
- xesmf=0.7.0
27-
- matplotlib-base=3.7.1
7+
# Base - required for building the package.
8+
# =========================================
9+
- python >=3.9
10+
- cf_xarray
11+
- cftime
12+
- dask
13+
- lxml
14+
- netcdf4
15+
- numpy >=1.23.0 # This version of numpy includes support for Python 3.11.
16+
- pandas
17+
- python-dateutil
18+
- xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9.
19+
- xgcm
20+
# Optional - enables additional features.
21+
# =========================================
22+
- xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212.
23+
- matplotlib-base >=3.7.0
2824
- nc-time-axis=1.4.1
29-
# ==================
3025
# Documentation
3126
# ==================
3227
- sphinx=5.3.0
@@ -37,25 +32,22 @@ dependencies:
3732
- pandoc=3.1.1
3833
- ipython=8.11.0 # Required for nbsphinx syntax highlighting
3934
- gsw-xarray=0.3.0 # Required for vertical regridding example
40-
# ==================
4135
# Quality Assurance
4236
# ==================
43-
# NOTE: If versions are updated, also update 'rev' in `.pre-commit.config.yaml`
44-
- black=23.1.0
37+
- types-python-dateutil
38+
# NOTE: If the tools below are updated, also update their 'rev' in `.pre-commit.config.yaml`
39+
- black=23.3.0
4540
- flake8=6.0.0
4641
- flake8-isort=6.0.0
4742
- isort=5.12.0
48-
- mypy=1.1.1
43+
- mypy=1.4.0
4944
- pre-commit=3.2.0
50-
- types-python-dateutil=2.8.19
51-
# ==================
5245
# Testing
5346
# ==================
54-
- pytest=7.2.2
55-
- pytest-cov=4.0.0
56-
# ==================
47+
- pytest
48+
- pytest-cov
5749
# Developer Tools
5850
# ==================
59-
- jupyterlab=3.6.2
60-
- tbump=6.9.0
51+
- jupyterlab
52+
- tbump
6153
prefix: /opt/miniconda3/envs/xcdat_dev

conda-env/readthedocs.yml

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

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,28 @@ exclude = '''
2121
)/
2222
)
2323
'''
24+
25+
[tool.isort]
26+
# Docs: https://pycqa.github.io/isort/docs/configuration/options.html#example-pyprojecttoml_4
27+
multi_line_output = 3
28+
include_trailing_comma = true
29+
force_grid_wrap = 0
30+
use_parentheses = true
31+
line_length = 88
32+
33+
[tool.pytest.ini_options]
34+
# Docs: https://docs.pytest.org/en/7.2.x/reference/customize.html#configuration
35+
junit_family = "xunit2"
36+
addopts = "--cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s"
37+
python_files = ["tests.py", "test_*.py"]
38+
# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module.
39+
markers = ["flaky", "network"]
40+
41+
[tool.mypy]
42+
# Docs: https://mypy.readthedocs.io/en/stable/config_file.html
43+
python_version = 3.10
44+
check_untyped_defs = true
45+
ignore_missing_imports = true
46+
warn_unused_ignores = true
47+
warn_redundant_casts = true
48+
warn_unused_configs = true

setup.cfg

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[flake8]
22
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes
3+
# flake8 dooes not support pyproject.toml yet: https://github.com/PyCQA/flake8/issues/234
34
ignore =
45
# whitespace before ‘:’
56
E203
@@ -23,45 +24,6 @@ exclude =
2324
*__init__.py
2425
venv
2526

26-
[isort]
27-
multi_line_output=3
28-
include_trailing_comma=True
29-
force_grid_wrap=0
30-
use_parentheses=True
31-
line_length=88
32-
33-
[pycodestyle]
34-
max-line-length = 119
35-
exclude =
36-
.tox
37-
.git
38-
*/migrations/*
39-
*/static/CACHE/*
40-
docs
41-
node_modules
42-
.idea
43-
.mypy_cache
44-
.pytest_cache
45-
*__init__.py
46-
venv
47-
48-
[mypy]
49-
python_version = 3.10
50-
check_untyped_defs = True
51-
ignore_missing_imports = True
52-
warn_unused_ignores = True
53-
warn_redundant_casts = True
54-
warn_unused_configs = True
55-
5627
[aliases]
5728
# Define setup.py command aliases here
5829
test = pytest
59-
60-
[tool:pytest]
61-
junit_family=xunit2
62-
addopts = --cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s
63-
python_files = tests.py test_*.py
64-
# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module.
65-
markers =
66-
flaky
67-
network

0 commit comments

Comments
 (0)