Skip to content

Commit 1e6991d

Browse files
authored
refactor/ci: drop Python 3.7, add Python 3.11 (#1662)
* drop Python 3.7, add Python 3.11 * update flake8 config in setup.cfg * enable rasterio & fiona optional deps on windows * disable vtk on Python 3.11 until published to PyPI * use importlib.metadata instead of pkg_resources * link to NEP 29 in DEVELOPER.md
1 parent bd51afa commit 1e6991d

File tree

10 files changed

+60
-57
lines changed

10 files changed

+60
-57
lines changed

.github/workflows/benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ ubuntu-latest, macos-latest, windows-latest ]
15-
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
15+
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
1616
exclude:
1717
# avoid shutil.copytree infinite recursion bug
1818
# https://github.com/python/cpython/pull/17098
@@ -115,7 +115,7 @@ jobs:
115115
- name: Setup Python
116116
uses: actions/setup-python@v4
117117
with:
118-
python-version: 3.7
118+
python-version: 3.8
119119
cache: 'pip'
120120
cache-dependency-path: setup.cfg
121121

.github/workflows/commit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Python
2525
uses: actions/setup-python@v4
2626
with:
27-
python-version: 3.7
27+
python-version: 3.8
2828
cache: 'pip'
2929
cache-dependency-path: setup.cfg
3030

@@ -57,7 +57,7 @@ jobs:
5757
- name: Setup Python
5858
uses: actions/setup-python@v4
5959
with:
60-
python-version: 3.7
60+
python-version: 3.8
6161
cache: 'pip'
6262
cache-dependency-path: setup.cfg
6363

@@ -113,7 +113,7 @@ jobs:
113113
- name: Setup Python
114114
uses: actions/setup-python@v4
115115
with:
116-
python-version: 3.7
116+
python-version: 3.8
117117
cache: 'pip'
118118
cache-dependency-path: setup.cfg
119119

@@ -149,7 +149,7 @@ jobs:
149149
fail-fast: false
150150
matrix:
151151
os: [ ubuntu-latest, macos-latest, windows-latest ]
152-
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
152+
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
153153
exclude:
154154
# avoid shutil.copytree infinite recursion bug
155155
# https://github.com/python/cpython/pull/17098

.github/workflows/examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ ubuntu-latest, macos-latest, windows-latest ]
15-
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
15+
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
1616
exclude:
1717
# avoid shutil.copytree infinite recursion bug
1818
# https://github.com/python/cpython/pull/17098

.github/workflows/regression.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [ ubuntu-latest, macos-latest, windows-latest ]
15-
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
15+
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
1616
exclude:
1717
# avoid shutil.copytree infinite recursion bug
1818
# https://github.com/python/cpython/pull/17098

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup Python
2828
uses: actions/setup-python@v4
2929
with:
30-
python-version: 3.7
30+
python-version: 3.8
3131
cache: 'pip'
3232
cache-dependency-path: setup.cfg
3333

@@ -214,7 +214,7 @@ jobs:
214214
- name: Setup Python
215215
uses: actions/setup-python@v4
216216
with:
217-
python-version: 3.7
217+
python-version: 3.8
218218
cache: 'pip'
219219
cache-dependency-path: setup.cfg
220220

@@ -343,7 +343,7 @@ jobs:
343343
- name: Setup Python
344344
uses: actions/setup-python@v4
345345
with:
346-
python-version: 3.7
346+
python-version: 3.8
347347
cache: 'pip'
348348
cache-dependency-path: setup.cfg
349349

@@ -393,4 +393,4 @@ jobs:
393393
394394
Updates the `develop` branch from `master` following a successful release. Increments the patch version number.
395395
'
396-
gh pr create -B "develop" -H "$reset_branch" --title "Reinitialize develop branch" --draft --body "$body"
396+
gh pr create -B "develop" -H "$reset_branch" --title "Reinitialize develop branch" --draft --body "$body"

DEVELOPER.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ GitHub's [Guide to Installing Git](https://help.github.com/articles/set-up-git)
4747

4848
### Python
4949

50-
Install Python 3.7.x or >=3.8.1, via [standalone download](https://www.python.org/downloads/) or a distribution like [Anaconda](https://www.anaconda.com/products/individual) or [miniconda](https://docs.conda.io/en/latest/miniconda.html). (An [infinite recursion bug](https://github.com/python/cpython/pull/17098) in 3.8.0's [`shutil.copytree`](https://github.com/python/cpython/commit/65c92c5870944b972a879031abd4c20c4f0d7981) can cause test failures if the destination is a subdirectory of the source.)
50+
FloPy supports several recent versions of Python, loosely following [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html#implementation).
51+
52+
Install Python >=3.8.1, via [standalone download](https://www.python.org/downloads/) or a distribution like [Anaconda](https://www.anaconda.com/products/individual) or [miniconda](https://docs.conda.io/en/latest/miniconda.html). (An [infinite recursion bug](https://github.com/python/cpython/pull/17098) in 3.8.0's [`shutil.copytree`](https://github.com/python/cpython/commit/65c92c5870944b972a879031abd4c20c4f0d7981) can cause test failures if the destination is a subdirectory of the source.)
5153

5254
Then install `flopy` and core dependencies from the project root:
5355

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For general modeling issues, please consult a modeling forum, such as the [MODFL
3030
Installation
3131
-----------------------------------------------
3232

33-
FloPy requires **Python** 3.7 (or higher), **NumPy** 1.15.0 (or higher), and **matplotlib** 1.4.0 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md).
33+
FloPy requires **Python** 3.8 (or higher), **NumPy** 1.15.0 (or higher), and **matplotlib** 1.4.0 (or higher). Dependencies for optional FloPy methods are summarized [here](docs/flopy_method_dependencies.md).
3434

3535
To install FloPy type:
3636

autotest/conftest.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import importlib
22
import os
3+
import re
34
import socket
45
import sys
6+
from importlib import metadata
57
from os import environ
68
from os.path import basename, normpath
79
from pathlib import Path
@@ -13,7 +15,6 @@
1315
from warnings import warn
1416

1517
import matplotlib.pyplot as plt
16-
import pkg_resources
1718
import pytest
1819
from modflow_devtools.misc import is_in_ci
1920

@@ -121,34 +122,40 @@ def pytest_addoption(parser):
121122
def pytest_report_header(config):
122123
"""Header for pytest to show versions of packages."""
123124

124-
# if we ever drop support for python 3.7, could use importlib.metadata instead?
125-
# or importlib_metadata backport: https://importlib-metadata.readthedocs.io/en/latest/
126-
# pkg_resources discouraged: https://setuptools.pypa.io/en/latest/pkg_resources.html
125+
required = []
126+
extra = {}
127+
for item in metadata.requires("flopy"):
128+
pkg_name = re.findall(r"[a-z0-9_\-]+", item, re.IGNORECASE)[0]
129+
if res := re.findall("extra == ['\"](.+)['\"]", item):
130+
assert len(res) == 1, item
131+
pkg_extra = res[0]
132+
if pkg_extra not in extra:
133+
extra[pkg_extra] = []
134+
extra[pkg_extra].append(pkg_name)
135+
else:
136+
required.append(pkg_name)
127137

128138
processed = set()
129-
flopy_pkg = pkg_resources.get_distribution("flopy")
130139
lines = []
131140
items = []
132-
for pkg in flopy_pkg.requires():
133-
name = pkg.name
141+
for name in required:
134142
processed.add(name)
135143
try:
136-
version = pkg_resources.get_distribution(name).version
144+
version = metadata.version(name)
137145
items.append(f"{name}-{version}")
138-
except pkg_resources.DistributionNotFound:
146+
except metadata.PackageNotFoundError:
139147
items.append(f"{name} (not found)")
140148
lines.append("required packages: " + ", ".join(items))
141149
installed = []
142150
not_found = []
143-
for pkg in flopy_pkg.requires(["optional"]):
144-
name = pkg.name
151+
for name in extra["optional"]:
145152
if name in processed:
146153
continue
147154
processed.add(name)
148155
try:
149-
version = pkg_resources.get_distribution(name).version
156+
version = metadata.version(name)
150157
installed.append(f"{name}-{version}")
151-
except pkg_resources.DistributionNotFound:
158+
except metadata.PackageNotFoundError:
152159
not_found.append(name)
153160
if installed:
154161
lines.append("optional packages: " + ", ".join(installed))

etc/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
# required
6-
- python>=3.7
6+
- python>=3.8
77
- numpy>=1.15.0
88
- matplotlib>=1.4.0
99

setup.cfg

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ classifiers =
2222
Operating System :: MacOS
2323
Programming Language :: Python
2424
Programming Language :: Python :: 3
25-
Programming Language :: Python :: 3.7
2625
Programming Language :: Python :: 3.8
2726
Programming Language :: Python :: 3.9
2827
Programming Language :: Python :: 3.10
28+
Programming Language :: Python :: 3.11
2929
Programming Language :: Python :: 3 :: Only
3030
Topic :: Scientific/Engineering :: Hydrology
3131
url = https://github.com/modflowpy/flopy
@@ -40,7 +40,7 @@ project_urls =
4040
include_package_data = True # includes files listed in MANIFEST.in
4141
zip_safe = False
4242
packages = find:
43-
python_requires = >=3.7
43+
python_requires = >=3.8
4444
install_requires =
4545
numpy >=1.15.0
4646
matplotlib >=1.4.0
@@ -70,18 +70,18 @@ test =
7070
optional =
7171
affine
7272
descartes
73-
fiona; platform_system!='Windows'
73+
fiona
7474
geojson
7575
netcdf4
7676
pandas
7777
pyproj
7878
pyshp
7979
python-dateutil >=2.4.0
80-
rasterio; platform_system!='Windows'
81-
rasterstats; platform_system!='Windows'
80+
rasterio
81+
rasterstats
8282
scipy
8383
shapely >=1.8
84-
vtk
84+
vtk; python_version<'3.11'
8585
xmipy
8686
doc =
8787
%(optional)s
@@ -118,28 +118,22 @@ exclude =
118118
autotest
119119
ignore =
120120
# https://flake8.pycqa.org/en/latest/user/error-codes.html
121-
F401 # 'module' imported but unused
121+
F401,
122122
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
123-
E121 # continuation line under-indented for hanging indent
124-
E122 # continuation line missing indentation or outdented
125-
E126 # continuation line over-indented for hanging indent
126-
E127 # continuation line over-indented for visual indent
127-
E128 # continuation line under-indented for visual indent
128-
E203 # whitespace before
129-
E221 # multiple spaces before operator
130-
E222 # multiple spaces after operator
131-
E226 # missing whitespace around arithmetic operator
132-
E231 # missing whitespace after ','
133-
E241 # multiple spaces after ','
134-
E402 # module level import not at top of file
135-
E501 # line too long (> 79 characters)
136-
E502 # backslash is redundant between brackets
137-
E722 # do not use bare 'except'
138-
E741 # ambiguous variable name
139-
W291 # trailing whitespace
140-
W292 # no newline at end of file
141-
W293 # blank line contains whitespace
142-
W391 # blank line at end of file
143-
W503 # line break before binary operator
144-
W504 # line break after binary operator
123+
# Indentation
124+
E121, E122, E126, E127, E128,
125+
# Whitespace
126+
E203, E221, E222, E226, E231, E241,
127+
# Import
128+
E402,
129+
# Line length
130+
E501, E502,
131+
# Statement
132+
E722, E741,
133+
# Whitespace warning
134+
W291, W292, W293,
135+
# Blank line warning
136+
W391,
137+
# Line break warning
138+
W503, W504
145139
statistics = True

0 commit comments

Comments
 (0)