Skip to content

Commit 028b8fa

Browse files
authored
Merge pull request #733 from nsidc/poetry-groups-to-pep621-optional-deps
Replace `poetry` with `pip`, build with `hatchling`, dynamically calculate minimum dependencies with `uv`
2 parents 699cc4e + de313be commit 028b8fa

25 files changed

+4556
-5646
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Install earthaccess Python package
2+
description: Install earthaccess Python package and testing dependencies
3+
4+
inputs:
5+
python-version:
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: ${{ inputs.python-version }}
14+
cache: pip
15+
16+
- name: Display full python version
17+
shell: bash
18+
id: full-python-version
19+
run: echo "{version}=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
20+
21+
- name: Install package and test dependencies
22+
shell: bash
23+
run: pip install .[test]

.github/workflows/integration-test.yml

+5-34
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ concurrency:
1717
group: integration-tests-${{ github.ref }}
1818
cancel-in-progress: true
1919

20-
defaults:
21-
run:
22-
shell: bash -l {0}
23-
2420
jobs:
2521
integration-tests:
2622
runs-on: ubuntu-latest
@@ -31,44 +27,19 @@ jobs:
3127

3228
steps:
3329
- uses: actions/checkout@v4
34-
- name: Set up Python
35-
uses: actions/setup-python@v5
30+
31+
- uses: ./.github/actions/install-pkg
3632
with:
3733
python-version: ${{ matrix.python-version }}
38-
- name: Get full python version
39-
id: full-python-version
40-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
41-
- name: Install poetry
42-
uses: abatilo/actions-poetry@v3
43-
- name: Configure poetry
44-
run: |
45-
poetry config virtualenvs.create true --local
46-
poetry config virtualenvs.in-project true --local
47-
poetry self add setuptools
48-
- name: Set up cache
49-
uses: actions/cache@v4
50-
id: cache
51-
with:
52-
path: .venv
53-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
54-
- name: Ensure cache is healthy
55-
if: steps.cache.outputs.cache-hit == 'true'
56-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
57-
- name: Install Dependencies
58-
if: ${{ !env.ACT }}
59-
run: poetry install
60-
- name: Install Dependencies
61-
if: ${{ env.ACT }}
62-
# When using `act` to run the workflow locally, the `poetry install` command
63-
# may fail due to network issues when running multiple Docker containers.
64-
run: poetry install || poetry install || poetry install
34+
6535
- name: Test
6636
env:
6737
EARTHDATA_USERNAME: ${{ secrets.EDL_USERNAME }}
6838
EARTHDATA_PASSWORD: ${{ secrets.EDL_PASSWORD }}
6939
EARTHACCESS_TEST_USERNAME: ${{ secrets.EDL_USERNAME }}
7040
EARTHACCESS_TEST_PASSWORD: ${{ secrets.EDL_PASSWORD }}
71-
run: poetry run bash scripts/integration-test.sh
41+
run: ./scripts/integration-test.sh
42+
7243
- name: Upload coverage
7344
# Don't upload coverage when using the `act` tool to run the workflow locally
7445
if: ${{ !env.ACT }}

.github/workflows/publish.yml

+23-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,32 @@ on:
55

66
jobs:
77
build:
8+
name: Build package
89
runs-on: ubuntu-latest
910
steps:
1011
- uses: actions/checkout@v4
12+
1113
- name: verify version matches git tag
1214
run: scripts/verify_tag.sh
13-
- name: Build and publish to pypi
14-
uses: JRubics/[email protected]
15+
16+
- uses: hynek/build-and-inspect-python-package@v2
17+
18+
publish:
19+
name: Publish to PyPI
20+
needs: ["build"]
21+
runs-on: ubuntu-latest
22+
environment: pypi
23+
permissions:
24+
id-token: write
25+
steps:
26+
- uses: actions/download-artifact@v4
27+
with:
28+
name: Packages
29+
path: dist
30+
31+
- uses: pypa/gh-action-pypi-publish@release/v1
32+
# NOTE: This is not the current best practice. Instead, we should use
33+
# "trusted publishing":
34+
# https://github.com/pypa/gh-action-pypi-publish?tab=readme-ov-file#trusted-publishing
1535
with:
16-
python_version: "3.9"
17-
pypi_token: ${{ secrets.PYPI_TOKEN }}
36+
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test-mindeps.yml

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test minimum dependencies
1+
name: Unit test minimum dependencies
22

33
on:
44
push:
@@ -11,11 +11,6 @@ concurrency:
1111
group: test-mindeps-${{ github.ref }}
1212
cancel-in-progress: true
1313

14-
# Required shell entrypoint to have properly activated conda environments
15-
defaults:
16-
run:
17-
shell: bash -l {0}
18-
1914
jobs:
2015
test-mindeps:
2116
runs-on: ubuntu-latest
@@ -25,25 +20,26 @@ jobs:
2520
steps:
2621
- name: Checkout source
2722
uses: actions/[email protected]
28-
- name: Setup Conda Environment
29-
uses: conda-incubator/[email protected]
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v2
26+
with:
27+
version: "0.4.7"
28+
enable-cache: true
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
3032
with:
31-
miniforge-variant: Mambaforge
32-
miniforge-version: latest
33-
use-mamba: true
34-
channel-priority: strict
35-
environment-file: ci/environment-mindeps.yaml
36-
activate-environment: test-environment
37-
auto-activate-base: false
33+
python-version-file: pyproject.toml
3834

39-
- name: Install
40-
run: python -m pip install --no-deps -e .
35+
- name: Install minimum-compatible dependencies
36+
run: uv sync --resolution lowest-direct --extra test
4137

42-
- name: mamba list
43-
run: mamba list
38+
- name: Install earthaccess
39+
run: uv pip install --no-deps .
4440

4541
- name: Test
46-
run: bash scripts/test.sh
42+
run: uv run pytest tests/unit --cov=earthaccess --cov=tests --cov-report=term-missing --capture=no --tb=native --log-cli-level=INFO
4743

4844
- name: Upload coverage
4945
# Don't upload coverage when using the `act` tool to run the workflow locally

.github/workflows/test.yml

+10-40
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ name: Unit Tests
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68
types: [opened, synchronize]
79

8-
defaults:
9-
run:
10-
shell: bash -l {0}
11-
1210
jobs:
1311
unit-tests:
1412
runs-on: ubuntu-latest
@@ -19,45 +17,17 @@ jobs:
1917

2018
steps:
2119
- uses: actions/checkout@v4
22-
- name: Set up Python
23-
uses: actions/setup-python@v5
20+
21+
- uses: ./.github/actions/install-pkg
2422
with:
2523
python-version: ${{ matrix.python-version }}
26-
- name: Get full python version
27-
id: full-python-version
28-
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
29-
- name: Install poetry
30-
uses: abatilo/actions-poetry@v3
31-
- name: Configure poetry
32-
run: |
33-
poetry config virtualenvs.create true --local
34-
poetry config virtualenvs.in-project true --local
35-
poetry self add setuptools
36-
- name: Set up mypy cache
37-
uses: actions/cache@v4
38-
id: mypy-cache
39-
with:
40-
path: .mypy_cache
41-
key: mypy-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
42-
- name: Set up cache
43-
uses: actions/cache@v4
44-
id: cache
45-
with:
46-
path: .venv
47-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
48-
- name: Ensure cache is healthy
49-
if: steps.cache.outputs.cache-hit == 'true'
50-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
51-
- name: Install Dependencies
52-
if: ${{ !env.ACT }}
53-
run: poetry install --quiet
54-
- name: Install Dependencies
55-
if: ${{ env.ACT }}
56-
# When using `act` to run the workflow locally, the `poetry install` command
57-
# may fail due to network issues when running multiple Docker containers.
58-
run: poetry install --quiet || poetry install --quiet || poetry install --quiet
24+
25+
- name: Typecheck
26+
run: mypy
27+
5928
- name: Test
60-
run: poetry run bash scripts/test.sh
29+
run: pytest tests/unit --cov=earthaccess --cov=tests --cov-report=term-missing --capture=no --tb=native --log-cli-level=INFO
30+
6131
- name: Upload coverage
6232
# Don't upload coverage when using the `act` tool to run the workflow locally
6333
if: ${{ !env.ACT }}

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ repos:
3333
- id: ruff
3434
args: ["--fix", "--exit-non-zero-on-fix"]
3535
- id: ruff-format
36+
37+
- repo: https://github.com/astral-sh/uv-pre-commit
38+
rev: "0.4.7"
39+
hooks:
40+
- id: uv-lock
41+
3642
- repo: https://github.com/google/yamlfmt
3743
rev: v0.13.0
3844
hooks:

Makefile

-48
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Visit [our quick start guide](https://earthaccess.readthedocs.io/en/latest/quick
8282

8383
## Compatibility
8484

85-
Only **Python 3.8+** is supported.
85+
The _minimum_ supported Python version is **3.9**.
8686

8787

8888
## How to Contribute to `earthaccess`

binder/environment.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ dependencies:
1818
- hvplot
1919
- holoviews
2020
- panel
21+
22+
- pip
23+
- pip:
24+
- "."

binder/postBuild

-6
This file was deleted.

ci/environment-dev.yml

-26
This file was deleted.

ci/environment-mindeps.yaml

-29
This file was deleted.

0 commit comments

Comments
 (0)