From 3a5d6da334d4dd89a39ebe5cd783247f9d6520e1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:28:18 +1300 Subject: [PATCH 01/15] Use uv package manager to test lowest versions in ci_tests_legacy.yaml Using uv's --resolution lowest-direct to install the lowest compatible versions for all direct Python dependencies (required and optional) listed in the pyproject.toml file. --- .github/workflows/ci_tests_legacy.yaml | 37 ++++++++++---------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 5ac5dcedbbc..3de6c99ce5d 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -1,8 +1,8 @@ -# Test PyGMT with GMT legacy versions on Linux/macOS/Windows +# Test PyGMT with GMT legacy versions and old Python dependencies on Linux/macOS/Windows # -# This workflow runs regular PyGMT tests with GMT legacy versions. Due to the minor -# baseline image changes between GMT versions, the workflow only runs the tests but -# doesn't do image comparisons. +# This workflow runs regular PyGMT tests with GMT legacy versions and old versions of +# all optional Python dependencies. Due to the minor baseline image changes between GMT +# versions, the workflow only runs the tests but doesn't do image comparisons. # # It is scheduled to run every Tuesday on the main branch. # @@ -62,23 +62,6 @@ jobs: python=3.10 gmt=${{ matrix.gmt_version }} ghostscript<10 - numpy - pandas - xarray - netCDF4 - packaging - contextily - geopandas - ipython - pyarrow - rioxarray - sphinx-gallery - make - pip - python-build - pytest - pytest-doctestplus - pytest-mpl # Download cached remote files (artifacts) from GitHub - name: Download remote data from GitHub @@ -95,10 +78,18 @@ jobs: env: GH_TOKEN: ${{ github.token }} + # Install uv package manager + - name: Install uv + uses: astral-sh/setup-uv@v3 + # Install the package that we want to test - name: Install the package - run: make install + run: | + uv run --with pip==23 --resolution lowest-direct --all-extras --dev make install + uv pip list # Run the tests but skip images - name: Run tests - run: make test_no_images PYTEST_EXTRA="-r P" + run: uv run --with pytest==8 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" + env: + GMT_LIBRARY_PATH: $CONDA_PREFIX/lib From f3039641a5dde5b46bf923f512734ef3aa8ea18c Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:29:04 +1300 Subject: [PATCH 02/15] Temporarily enable ci_tests_legacy.yaml --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 3de6c99ce5d..e1a292dad03 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -12,7 +12,7 @@ on: # push: # branches: [ main ] # Uncomment the 'pull_request' line below to trigger the workflow in PR - # pull_request: + pull_request: # types: [ready_for_review] # paths: # - 'pygmt/**' From 3f6909d0105580158a911f18fa9e18c1ba1f5910 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:44:37 +1300 Subject: [PATCH 03/15] Pin to netCDF>=1.7 Need to get more recent version with a binary wheel, otherwise will need to compile from source. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8400da80625..04886c6d1be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "numpy>=1.24", "pandas>=2.0", "xarray>=2023.04", - "netCDF4", + "netCDF4>=1.7", "packaging", ] dynamic = ["version"] From 788fc461e6fa73415761ab791f1fa3f250717f70 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:51:53 +1300 Subject: [PATCH 04/15] Pin contextily>=1, IPython>=8, pyarrow>=14 Pin major versions for optional dependencies that are not on version 0.x. Using a reasonable major version released in the past year or two. --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 04886c6d1be..8bea1e75bfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,10 +40,10 @@ dynamic = ["version"] [project.optional-dependencies] all = [ - "contextily", + "contextily>=1", "geopandas", - "IPython", # 'ipython' is not the correct module name. - "pyarrow", + "IPython>=8", # 'ipython' is not the correct module name. + "pyarrow>=14", "rioxarray", ] From 4139f4e2b177bc89688d35d6f1b0b768251cab1f Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:57:19 +1300 Subject: [PATCH 05/15] Pin geopandas>=0.14, rioxarray>=0.14 Pin minor versions of optional dependencies that are still on v0.x. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8bea1e75bfe..63edd180f62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,10 +41,10 @@ dynamic = ["version"] [project.optional-dependencies] all = [ "contextily>=1", - "geopandas", + "geopandas>=0.14", "IPython>=8", # 'ipython' is not the correct module name. "pyarrow>=14", - "rioxarray", + "rioxarray>=0.14", ] [project.urls] From 12630755aba4b1274a5e088df08ce2ef198d2d02 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:16:10 +1300 Subject: [PATCH 06/15] Add --color=yes to test_no_images addopts Xref #3330 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4494f2996c3..2dd8243f95d 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ doctest: _runtest # run tests without image comparisons # run pytest without the --mpl option to disable image comparisons # use '-o addopts' to override 'addopts' settings in pyproject.toml file -test_no_images: PYTEST_ARGS=-o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules" +test_no_images: PYTEST_ARGS=-o addopts="--verbose --color=yes --durations=0 --durations-min=0.2 --doctest-modules" test_no_images: _runtest format: From d1fa38d2393c613af8ef4149744beb6e7681683e Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:24:43 +1300 Subject: [PATCH 07/15] Pin packaging>=22.0 Fix `TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'` when running `pip install --no-deps -e .`, xref https://github.com/pypa/setuptools/issues/4501 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 63edd180f62..02acde598e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "pandas>=2.0", "xarray>=2023.04", "netCDF4>=1.7", - "packaging", + "packaging>=22.0", ] dynamic = ["version"] From 1c69406e3ee9dbee35ea9424230d55c0c120d363 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:40:03 +1300 Subject: [PATCH 08/15] Test with pytest-mpl and pytest-doctestplus --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index e1a292dad03..b583e9ba748 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -90,6 +90,6 @@ jobs: # Run the tests but skip images - name: Run tests - run: uv run --with pytest==8 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" + run: uv run --with pytest==8,pytest-mpl==0.17,pytest-doctestplus==1.2 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" env: GMT_LIBRARY_PATH: $CONDA_PREFIX/lib From 3b7b777d3046d0762e067367d8d87e6123db4c9a Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:12:36 +1300 Subject: [PATCH 09/15] Install into uv venv Create a proper virtualenv, and activate that virtualenv before installing pygmt and running pytest. --- .github/workflows/ci_tests_legacy.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index b583e9ba748..ded4472b2ea 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -85,11 +85,15 @@ jobs: # Install the package that we want to test - name: Install the package run: | + uv venv + source .venv/bin/activate uv run --with pip==23 --resolution lowest-direct --all-extras --dev make install uv pip list # Run the tests but skip images - name: Run tests - run: uv run --with pytest==8,pytest-mpl==0.17,pytest-doctestplus==1.2 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" + run: | + source .venv/bin/activate + uv run --with pytest==8,pytest-mpl==0.17,pytest-doctestplus==1.2 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" env: GMT_LIBRARY_PATH: $CONDA_PREFIX/lib From 6120bbe31a78ad8df5a005f983d3378e08756396 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:00:19 +1300 Subject: [PATCH 10/15] Pin contextily>=1.2 So that xyzservices is also installed by default and `from xyzservices import TileProvider` can work. See https://github.com/geopandas/contextily/pull/183 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 02acde598e7..3504543902e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dynamic = ["version"] [project.optional-dependencies] all = [ - "contextily>=1", + "contextily>=1.2", "geopandas>=0.14", "IPython>=8", # 'ipython' is not the correct module name. "pyarrow>=14", From 3299229ef398ae1e6d7365e7591b781d12f05835 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:19:15 +1300 Subject: [PATCH 11/15] Pin pyarrow>=16 So that `pyarrow.array(..., dtype="string_view")` will work. See https://github.com/apache/arrow/pull/39652 when this was added. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3504543902e..c680a77c17f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ all = [ "contextily>=1.2", "geopandas>=0.14", "IPython>=8", # 'ipython' is not the correct module name. - "pyarrow>=14", + "pyarrow>=16", "rioxarray>=0.14", ] From 7d542a91040787d8ed81bab050d16b931b5ab9df Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:25:32 +1300 Subject: [PATCH 12/15] Update wording on ci_tests_legacy.yaml header comment --- .github/workflows/ci_tests_legacy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index ded4472b2ea..716032b6045 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -1,8 +1,8 @@ # Test PyGMT with GMT legacy versions and old Python dependencies on Linux/macOS/Windows # # This workflow runs regular PyGMT tests with GMT legacy versions and old versions of -# all optional Python dependencies. Due to the minor baseline image changes between GMT -# versions, the workflow only runs the tests but doesn't do image comparisons. +# all optional and required Python dependencies. Due to minor baseline image changes +# between GMT versions, the workflow runs the tests but doesn't do image comparisons. # # It is scheduled to run every Tuesday on the main branch. # From 4733bda9e710061e79acafc771f8d0b1e32100e8 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 22 Nov 2024 21:56:56 +1300 Subject: [PATCH 13/15] Pin pyarrow>=13 and use pytest.mark.skipif on string_view type test Lower pyarrow pin from 16 to 13, and added a skipif pytest marker to the `test_to_numpy_pyarrow_array_pyarrow_dtypes_string[string_view]` unit test to not run when pyarrow<16 is installed. Setting a pin on pyarrow>=13 so that datetime64 unit preservation is handled, xref https://github.com/apache/arrow/issues/33321. --- pygmt/tests/test_clib_to_numpy.py | 9 ++++++++- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_clib_to_numpy.py b/pygmt/tests/test_clib_to_numpy.py index 02b65062da8..88845d31f2a 100644 --- a/pygmt/tests/test_clib_to_numpy.py +++ b/pygmt/tests/test_clib_to_numpy.py @@ -10,6 +10,7 @@ import pandas as pd import pytest from packaging.version import Version +from pygmt._show_versions import _get_module_version from pygmt.clib.conversion import _to_numpy from pygmt.helpers.testing import skip_if_no @@ -323,7 +324,13 @@ def test_to_numpy_pyarrow_array_pyarrow_dtypes_numeric_with_na(dtype, expected_d "utf8", # alias for string "large_string", "large_utf8", # alias for large_string - "string_view", + pytest.param( + "string_view", + marks=pytest.mark.skipif( + Version(_get_module_version("pyarrow")) < Version("16"), + reason="string_view type was added since pyarrow 16", + ), + ), ], ) def test_to_numpy_pyarrow_array_pyarrow_dtypes_string(dtype): diff --git a/pyproject.toml b/pyproject.toml index c680a77c17f..88cc042848c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ all = [ "contextily>=1.2", "geopandas>=0.14", "IPython>=8", # 'ipython' is not the correct module name. - "pyarrow>=16", + "pyarrow>=13", "rioxarray>=0.14", ] From 52c78fa378aafa1463abbcf2a98216fde114fcfa Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:56:24 +1300 Subject: [PATCH 14/15] Remove unused import _get_module_version --- pygmt/tests/test_clib_to_numpy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/tests/test_clib_to_numpy.py b/pygmt/tests/test_clib_to_numpy.py index bed8b32247f..64db3ea6547 100644 --- a/pygmt/tests/test_clib_to_numpy.py +++ b/pygmt/tests/test_clib_to_numpy.py @@ -10,7 +10,6 @@ import pandas as pd import pytest from packaging.version import Version -from pygmt._show_versions import _get_module_version from pygmt.clib.conversion import _to_numpy from pygmt.helpers.testing import skip_if_no From af01f751853ad650ec82ccaefd68cbf93d98889a Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:20:43 +1300 Subject: [PATCH 15/15] Bump astral-sh/setup-uv from 3 to 5.1.0 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 3to 5.1.0. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v5.1.0) Includes auto activate venv when python-version is set, xref https://github.com/astral-sh/setup-uv/pull/194 --- .github/workflows/ci_tests_legacy.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 8abb317f9a1..f0c91592a3f 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -80,20 +80,18 @@ jobs: # Install uv package manager - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v5.1.0 + with: + python-version: 3.11 # Install the package that we want to test - name: Install the package run: | - uv venv - source .venv/bin/activate uv run --with pip==23 --resolution lowest-direct --all-extras --dev make install uv pip list # Run the tests but skip images - name: Run tests - run: | - source .venv/bin/activate - uv run --with pytest==8,pytest-mpl==0.17,pytest-doctestplus==1.2 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" + run: uv run --with pytest==8,pytest-mpl==0.17,pytest-doctestplus==1.2 --resolution lowest-direct --all-extras --dev make test_no_images PYTEST_EXTRA="-r P" env: GMT_LIBRARY_PATH: $CONDA_PREFIX/lib