From 2138feeec3fb9e3219b5d709b713c41269363267 Mon Sep 17 00:00:00 2001 From: Derrick Chambers Date: Tue, 24 Dec 2024 07:55:11 -0800 Subject: [PATCH] Add support for python 3.13 (#473) --- .../workflows/build_deploy_master_docs.yaml | 2 +- .../workflows/build_deploy_stable_docs.yaml | 31 ++++++++++++------- .github/workflows/run_min_dep_tests.yml | 29 ++++++----------- .github/workflows/runtests.yml | 2 +- .gitignore | 1 + pyproject.toml | 2 +- tests/test_utils/test_doc_utils.py | 4 ++- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build_deploy_master_docs.yaml b/.github/workflows/build_deploy_master_docs.yaml index adf86cca..7eba9f55 100644 --- a/.github/workflows/build_deploy_master_docs.yaml +++ b/.github/workflows/build_deploy_master_docs.yaml @@ -62,7 +62,7 @@ jobs: shell: bash -l {0} run: | conda install -c conda-forge pandoc - python -m pip install -e .[docs] + python -m pip install -e .[docs,all] - name: Install quarto uses: quarto-dev/quarto-actions/setup@v2 diff --git a/.github/workflows/build_deploy_stable_docs.yaml b/.github/workflows/build_deploy_stable_docs.yaml index 75110ec5..140bffa3 100644 --- a/.github/workflows/build_deploy_stable_docs.yaml +++ b/.github/workflows/build_deploy_stable_docs.yaml @@ -38,25 +38,32 @@ jobs: run: | git fetch --tags --force # Retrieve annotated tags. - - name: Get tags - run: git fetch --tags origin - - - name: Setup conda - uses: conda-incubator/setup-miniconda@v3 + - uses: mamba-org/setup-micromamba@v2 with: - python-version: "3.11" - mamba-version: "*" - channels: conda-forge,defaults - channel-priority: true - activate-environment: dascore + micromamba-version: '2.0.2-1' # versions: https://github.com/mamba-org/micromamba-releases environment-file: environment.yml - condarc-file: .github/test_condarc.yml + init-shell: >- + bash + powershell + cache-environment: true + cache-environment-key: environment-${{ steps.date.outputs.date }} + post-cleanup: 'all' + create-args: >- + python=${{ matrix.python-version }} + + # Not sure why this is needed but it appears to be the case + - name: fix env + shell: bash -l {0} + run: | + micromamba shell init --shell bash --root-prefix=~/micromamba + eval "$(micromamba shell hook --shell bash)" + micromamba activate dascore - name: install dascore with docbuild reqs shell: bash -l {0} run: | conda install -c conda-forge pandoc - python -m pip install -e .[docs] + python -m pip install -e .[docs,all] - name: Install quarto uses: quarto-dev/quarto-actions/setup@v2 diff --git a/.github/workflows/run_min_dep_tests.yml b/.github/workflows/run_min_dep_tests.yml index c7e74057..3651a8c3 100644 --- a/.github/workflows/run_min_dep_tests.yml +++ b/.github/workflows/run_min_dep_tests.yml @@ -10,7 +10,7 @@ on: paths: - 'pyproject.toml' - '**.py' - - '.github/workflows/runtests.yml' + - '.github/workflows/run_min_dep_tests.yml' env: # used to manually trigger cache reset. Just increment if needed. @@ -29,10 +29,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: -# os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest] - - python-version: ['3.12'] + python-version: ['3.12', '3.13'] # only run if CI isn't turned off if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci') @@ -50,7 +48,6 @@ jobs: run: | git fetch --tags --force # Retrieve annotated tags. - # Have to use conda to install hdf5 so mac (I guess m1/2) runners work. - uses: mamba-org/setup-micromamba@v2 with: micromamba-version: '2.0.2-1' # versions: https://github.com/mamba-org/micromamba-releases @@ -64,7 +61,8 @@ jobs: create-args: >- python=${{ matrix.python-version }} - # Not sure why this is needed but it appears to be the case + # Not sure why this is needed but it appears to be the case. + # Also installs pytables so hdf5 gets installed on windows - name: fix env shell: bash -l {0} run: | @@ -72,27 +70,20 @@ jobs: eval "$(micromamba shell hook --shell bash)" micromamba activate dascore - - name: print python version - shell: bash -el {0} - run: | - python --version - - name: install hdf5 - if: matrix.os=='macos-latest' shell: bash -l {0} run: | micromamba install pytables - - name: install dascore - shell: bash -l {0} - run: | - python -m pip install -e .[test] + # Then switch over to uv. We can use this exclusively once we drop pytables. + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: set data cache path shell: bash -l {0} run: | export PATH="$pythonLocation:$PATH" - echo "DATA_CACHE_PATH=$(python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV + echo "DATA_CACHE_PATH=$(uv run --extra test python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV - name: cache test data uses: actions/cache@v3 @@ -103,9 +94,9 @@ jobs: - name: run test suite shell: bash -l {0} - run: ./.github/test_code.sh + run: uv run --extra test --python ${{ matrix.python-version }} pytest -s --cov dascore --cov-append --cov-report=xml # Runs examples in docstrings - name: test docstrings shell: bash -l {0} - run: ./.github/test_code.sh doctest + run: uv run --extra test --python ${{ matrix.python-version }} pytest dascore --doctest-modules diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index 1d329ce0..f36ec01b 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -14,7 +14,7 @@ on: env: # used to manually trigger cache reset. Just increment if needed. - CACHE_NUMBER: 2 + CACHE_NUMBER: 1 # Cancel previous runs when this one starts. concurrency: diff --git a/.gitignore b/.gitignore index 2c426cf9..c119d171 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,7 @@ docs/**/*.ipynb # misc scratch/** .ruff_cache +uv.lock docs/index_files docs/index.quarto_ipynb diff --git a/pyproject.toml b/pyproject.toml index 33ce54be..61555689 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ extras = [ "findiff", "obspy", "numba", - "segyio", + "segyio", ] docs = [ diff --git a/tests/test_utils/test_doc_utils.py b/tests/test_utils/test_doc_utils.py index b9f0fa52..36623d48 100644 --- a/tests/test_utils/test_doc_utils.py +++ b/tests/test_utils/test_doc_utils.py @@ -51,7 +51,9 @@ def testfun1(): assert "Parameters" in testfun1.__doc__ line = next(x for x in testfun1.__doc__.split("\n") if "Parameters" in x) base_spaces = line.split("Parameters")[0] - assert len(base_spaces) == 12 + # py3.13+ automatically strips white space from docstrings so 12 + # and 0 are valid lengths. + assert len(base_spaces) in {12, 0} def test_list_indent(self): """Ensure lists are indented equally."""