From 52c98e023529b4a0dc75c21e8dbdbdf84d8fd65a Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Mon, 3 Apr 2023 17:07:25 -0300 Subject: [PATCH 01/10] add pandas 2.0 test --- gsw/tests/test_xarray.py | 13 +++++++++++++ requirements-dev.txt | 1 + 2 files changed, 14 insertions(+) diff --git a/gsw/tests/test_xarray.py b/gsw/tests/test_xarray.py index e424dd4..0d95550 100644 --- a/gsw/tests/test_xarray.py +++ b/gsw/tests/test_xarray.py @@ -14,6 +14,9 @@ import numpy as np from numpy.testing import assert_allclose +import pandas as pd + + import gsw from gsw._utilities import Bunch from check_functions import parse_check_functions @@ -141,3 +144,13 @@ def test_xarray_with_coords(): chunked = gsw.z_from_p(p,lat_chunk) assert_allclose(xarray, expected) assert_allclose(chunked, expected) + +def test_pandas_20(): + df = pd.DataFrame( + { + "pressure": [0, 10, 20], + "latitude": [70, 70, 70], + } + ) + depth = -1 * gsw.z_from_p(df["pressure"], df["latitude"]) + assert isinstance(depth, pd.core.series.Series) \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 7ba2df0..6876fea 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,4 +7,5 @@ sphinx sphinx_rtd_theme twine xarray +pandas>=2 dask From fe75070fe0222f4f7ff169de08fb6a8098df39a7 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 08:36:19 -0300 Subject: [PATCH 02/10] update and lint pyproject.toml --- .pre-commit-config.yaml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e1dc55..26c0d36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast - id: debug-statements - id: check-added-large-files - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell exclude: > @@ -17,3 +17,19 @@ repos: )$ args: - --ignore-words-list=nin,preformed,wih, + +- repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.9.2 + hooks: + - id: pyproject-fmt + +ci: + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit.com hooks + + for more information, see https://pre-commit.ci + autofix_prs: false + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: monthly + skip: [] + submodules: false From 3d4a87ef87d552d6b8edc1024d27a3fd9a2d5968 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 08:36:30 -0300 Subject: [PATCH 03/10] exclude GH stuff --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 26612e3..b8e1b24 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,7 @@ recursive-include src *.h include src/c_gsw/LICENSE prune docs +prune .github prune tools prune notebooks prune *.egg-info From c832561df86a88641cf6a04dee6aee2322796c40 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 08:49:36 -0300 Subject: [PATCH 04/10] move all metadata to pyproject.toml --- .pre-commit-config.yaml | 6 +++ pyproject.toml | 95 ++++++++++++++++++++++++++++++++++++++++- setup.cfg | 47 -------------------- setup.py | 8 ---- 4 files changed, 100 insertions(+), 56 deletions(-) delete mode 100644 setup.cfg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26c0d36..d66864e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,6 +23,12 @@ repos: hooks: - id: pyproject-fmt + +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.260 + hooks: + - id: ruff + ci: autofix_commit_msg: | [pre-commit.ci] auto fixes from pre-commit.com hooks diff --git a/pyproject.toml b/pyproject.toml index 5bc1231..6df650c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,96 @@ [build-system] -requires = ["pip>9.0.1", "setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "oldest-supported-numpy", "build"] build-backend = "setuptools.build_meta" +requires = [ + "build", + "oldest-supported-numpy", + "pip>9.0.1", + "setuptools>=42", + "setuptools_scm[toml]>=3.4", + "wheel", +] + +[project] +name = "gsw" +description = "Gibbs Seawater Oceanographic Package of TEOS-10" +license = {text = "BSD-3-Clause"} +authors = [ + {name = "Eric Firing, Filipe Fernandes", email = "efiring@hawaii.edu"}, +] +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", +] +dynamic = [ + "readme", + "version", +] +[project.urls] +documentation = "https://teos-10.github.io/GSW-Python/" +homepage = "https://www.teos-10.org/" +repository = "https://github.com/TEOS-10/GSW-python" + +[tool.setuptools] +license-files = ["LICENSE.txt"] +zip-safe = false +include-package-data = true + +[tool.setuptools.packages.find] +where = ["gsw"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +readme = {file = "README.md", content-type = "text/markdown"} + +[tool.setuptools_scm] +write_to = "gsw/_version.py" +write_to_template = "__version__ = '{version}'" + +[tool.check-manifest] +ignore = [ + "*.yml", + ".coveragerc", + "docs", + "docs/*", + "*.enc", + "tools", + "tools/*", + "gsw/_version.py", +] + +[tool.ruff] +select = [ + "A", # flake8-builtins + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "F", # flakes + "I", # import sorting + # "T20", # flake8-print + "UP", # upgrade +] +target-version = "py38" +line-length = 105 + +ignore = [ + "F401", + "E501", + "E713", +] + +exclude = [ + "tools", +] + +[tool.ruff.per-file-ignores] +"docs/source/conf.py" = [ + "A001", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7ce214b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ -[metadata] -name = gsw -description = Gibbs Seawater Oceanographic Package of TEOS-10 -author = Eric Firing, Filipe Fernandes -author_email = efiring@hawaii.edu -url = https://github.com/TEOS-10/GSW-python -long_description = file: README.md -long_description_content_type = text/markdown -license = BSD -license_file = LICENSE.txt -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Science/Research - Operating System :: OS Independent - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Scientific/Engineering - - -[options] -zip_safe = False -install_requires = - numpy -python_requires = >=3.8 -packages = find: -include_package_data = True - -[check-manifest] -ignore = - *.yml - .coveragerc - docs - docs/* - *.enc - tools - tools/* - gsw/_version.py - -[flake8] -max-line-length = 105 -select = C,E,F,W,B,B950 -ignore = E203, E501, W503, E713 diff --git a/setup.py b/setup.py index 2d05343..a94b43d 100644 --- a/setup.py +++ b/setup.py @@ -50,14 +50,6 @@ def build_extensions(self): ] config = { - # The package metadata is specified in setup.cfg but GitHub's downstream dependency graph - # does not work unless we put the name this here too. - "name": "gsw", - "use_scm_version": { - "write_to": "gsw/_version.py", - "write_to_template": '__version__ = "{version}"', - "tag_regex": r"^(?Pv)?(?P[^\+]+)(?P.*)?$", - }, "ext_modules": [Extension("gsw._gsw_ufuncs", ufunc_src_list)], "include_dirs": [os.path.join(rootpath, "src", "c_gsw")], "cmdclass": {"build_ext": build_ext}, From 2c54474063ff20a79adbf14e1af0479425cd5ac5 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 09:07:05 -0300 Subject: [PATCH 05/10] list packages, find is still beta --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6df650c..bb35bae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,9 +43,8 @@ repository = "https://github.com/TEOS-10/GSW-python" license-files = ["LICENSE.txt"] zip-safe = false include-package-data = true +packages = ["gsw", "gsw.tests"] -[tool.setuptools.packages.find] -where = ["gsw"] [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} From a1b6f8fda155aac104dd96ab6e0f1123d248c885 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 09:08:04 -0300 Subject: [PATCH 06/10] this was moved to main lic file --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index b8e1b24..4fa7475 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,6 @@ include README.md graft gsw recursive-include src *.c recursive-include src *.h -include src/c_gsw/LICENSE prune docs prune .github From 6d01d5da9ba4635fd0060020770a2ac5da62e9d4 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 09:17:46 -0300 Subject: [PATCH 07/10] oldest-numpy does not exclude us from listing numpy again --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bb35bae..0a18ca9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,9 @@ dynamic = [ "readme", "version", ] +dependencies = [ + "numpy>=1.21", +] [project.urls] documentation = "https://teos-10.github.io/GSW-Python/" homepage = "https://www.teos-10.org/" From 54849cb13a844a3854e4bcf7a23a653933857040 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 09:22:06 -0300 Subject: [PATCH 08/10] run all tests with wheels --- .github/workflows/cibuildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 58f3aad..f744ee6 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -42,7 +42,7 @@ jobs: CIBW_BUILD_FRONTEND: build CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_TEST_SKIP: "*_arm64" - CIBW_TEST_REQUIRES: pytest + CIBW_TEST_REQUIRES: pytest xarray CIBW_TEST_COMMAND: > python -c "import gsw; print(f'gsw v{gsw.__version__}')" && python -m pytest --pyargs gsw From 8f02933a947a499477ff184bb3de075a479db2bd Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 09:27:52 -0300 Subject: [PATCH 09/10] xarray is not compat with pd 2 yet --- .github/workflows/cibuildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index f744ee6..3492be9 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -42,7 +42,7 @@ jobs: CIBW_BUILD_FRONTEND: build CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_TEST_SKIP: "*_arm64" - CIBW_TEST_REQUIRES: pytest xarray + CIBW_TEST_REQUIRES: pytest pandas>=2 CIBW_TEST_COMMAND: > python -c "import gsw; print(f'gsw v{gsw.__version__}')" && python -m pytest --pyargs gsw From ea8d309227df5dfea445a2ad1833a8170bda7572 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 4 Apr 2023 14:24:47 -0300 Subject: [PATCH 10/10] use same regex --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0a18ca9..a19aae0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ readme = {file = "README.md", content-type = "text/markdown"} [tool.setuptools_scm] write_to = "gsw/_version.py" write_to_template = "__version__ = '{version}'" +tag_regex = "^(?Pv)?(?P[^\\+]+)(?P.*)?$" [tool.check-manifest] ignore = [