Skip to content

Commit ea833fd

Browse files
authoredFeb 5, 2025··
build: uv in tests and ci (#91)
1 parent 10e630f commit ea833fd

File tree

6 files changed

+54
-76
lines changed

6 files changed

+54
-76
lines changed
 

‎.github/workflows/deploy.yml

+13-14
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ jobs:
1313

1414
steps:
1515
- name: Checkout source
16-
uses: actions/checkout@v2
17-
18-
- name: Set up Python 3.9
19-
uses: actions/setup-python@v2
16+
uses: actions/checkout@v4
2017
with:
21-
python-version: "3.9"
22-
18+
# Get history and tags for SCM versioning to work
19+
fetch-depth: 0
20+
- name: Install the latest version of uv with cache enabled
21+
uses: astral-sh/setup-uv@v3
22+
with:
23+
version: "latest"
24+
enable-cache: true
25+
cache-dependency-glob: ""
2326
- name: Check that the current version isn't already on PyPi
2427
run: |
25-
if [ "$(./get_pypi_latest_version.sh)" != "$(python setup.py --version)" ]
28+
if [ "$(./get_pypi_latest_version.sh)" != "$(git describe --tags)" ]
2629
then
2730
echo "Current version is not on PyPI, proceed with bulding"
2831
else
@@ -31,15 +34,11 @@ jobs:
3134
fi
3235
3336
- name: Check long description is OK for PyPI with tox
34-
run: |
35-
python -m pip install --upgrade pip
36-
python -m pip install tox sphinx
37-
tox -e pypi
37+
run: uvx --with tox-uv --with sphinx tox -e pypi
3838

3939
- name: Build a binary wheel and a source tarball
40-
run: |
41-
python -m pip install setuptools wheel
42-
python setup.py sdist bdist_wheel
40+
run: uvx --from build pyproject-build --sdist --wheel
41+
4342
- name: Publish distribution to PyPI
4443
uses: pypa/gh-action-pypi-publish@release/v1
4544
with:

‎.github/workflows/test.yml

+32-55
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ on:
1111

1212
jobs:
1313
lint:
14-
name: Linting (pre-commit)
14+
name: Linting (pre-commit and mypy)
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout the repo
18-
uses: actions/checkout@v2
19-
- name: Set up Python 3.9
20-
uses: actions/setup-python@v2
18+
uses: actions/checkout@v4
2119
with:
22-
python-version: "3.9"
23-
- name: Run pre-commit action
24-
uses: pre-commit/action@v2.0.0
20+
# Get history and tags for SCM versioning to work
21+
fetch-depth: 0
22+
- name: Install the latest version of uv with cache enabled
23+
uses: astral-sh/setup-uv@v3
24+
with:
25+
version: "latest"
26+
enable-cache: true
27+
cache-dependency-glob: ""
28+
- name: Run linters with tox
29+
run: uvx --python 3.9 --with tox-uv tox -e linters
2530

2631
tests:
2732
name: Test it!
@@ -32,61 +37,33 @@ jobs:
3237
os: [ubuntu-latest, windows-latest]
3338
steps:
3439
- name: Checkout the repo
35-
uses: actions/checkout@v2
36-
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
37-
uses: actions/setup-python@v2
40+
uses: actions/checkout@v4
3841
with:
39-
python-version: ${{ matrix.python-version }}
40-
- name: Update pip
41-
run: python -m pip install --upgrade pip
42-
- name: Get pip cache dir
43-
id: pip-cache
44-
run: |
45-
echo "::set-output name=dir::$(pip cache dir)"
46-
- name: Get current week number
47-
id: get-week
48-
shell: bash
49-
run: echo "::set-output name=week::$(date +'%V')"
50-
- name: Pip cache
51-
uses: actions/cache@v2
42+
# Get history and tags for SCM versioning to work
43+
fetch-depth: 0
44+
- name: Install the latest version of uv with cache enabled
45+
uses: astral-sh/setup-uv@v3
5246
with:
53-
path: ${{ steps.pip-cache.outputs.dir }}
54-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ steps.get-week.outputs.week }}-${{ hashFiles('setup.py') }}
55-
- name: Enable long paths on Windows and Git
56-
if: runner.os == 'Windows'
57-
run: git config --global core.longpaths true
58-
- name: Install other deps
59-
run: python -m pip install .[dev]
60-
- name: Test with pytest
61-
run: pytest --show-capture=no --cov --cov-fail-under=50
47+
version: "latest"
48+
enable-cache: true
49+
cache-dependency-glob: ""
50+
- name: Test with tox
51+
run: uvx --python ${{ matrix.python-version }} --with tox-uv --with tox-gh-actions tox
6252

6353
check-pypi:
6454
name: Long description check for PyPI
6555
runs-on: ubuntu-latest
6656
steps:
6757
- name: Checkout the repo
68-
uses: actions/checkout@v2
69-
- name: Set up Python 3.9
70-
uses: actions/setup-python@v2
58+
uses: actions/checkout@v4
7159
with:
72-
python-version: "3.9"
73-
- name: Update pip
74-
run: python -m pip install --upgrade pip
75-
- name: Get pip cache dir
76-
id: pip-cache
77-
run: |
78-
echo "::set-output name=dir::$(pip cache dir)"
79-
- name: Get current week number
80-
id: get-week
81-
shell: bash
82-
run: echo "::set-output name=week::$(date +'%V')"
83-
- name: Pip cache
84-
uses: actions/cache@v2
60+
# Get history and tags for SCM versioning to work
61+
fetch-depth: 0
62+
- name: Install the latest version of uv with cache enabled
63+
uses: astral-sh/setup-uv@v3
8564
with:
86-
path: ${{ steps.pip-cache.outputs.dir }}
87-
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.week }}-${{ hashFiles('setup.py') }}
88-
- name: Install tox and sphinx (to have rst2html.py utility available)
89-
run: |
90-
python -m pip install tox sphinx
91-
- name: Testing with tox
92-
run: python -m tox -e pypi
65+
version: "latest"
66+
enable-cache: true
67+
cache-dependency-glob: ""
68+
- name: Testing with tox and sphinx (to have rst2html.py utility available)
69+
run: uvx --with tox-uv --with sphinx tox -e pypi

‎pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.uv]
2+
cache-keys = [{ git = true }]

‎setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"pytest",
4545
"pytest-cov",
4646
"tox",
47+
"tox-uv",
4748
"nose",
4849
"faker",
4950
"coverage",
@@ -55,7 +56,7 @@
5556
},
5657
zip_safe=False,
5758
classifiers=[
58-
"Development Status :: 1 - Planning",
59+
"Development Status :: 5 - Production/Stable",
5960
"Intended Audience :: Developers",
6061
"Intended Audience :: Science/Research",
6162
"Natural Language :: English",

‎tests/units/test_eoproduct_driver_generic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
EOProduct,
3232
GenericDriver,
3333
UnsupportedDatasetAddressScheme,
34+
path_to_uri,
3435
)
3536

3637

@@ -105,7 +106,7 @@ def _filesystem_product(self):
105106
def _grib_product(self):
106107
original = self.product.location
107108
try:
108-
self.product.location = f"file://{TEST_GRIB_PRODUCT_PATH}"
109+
self.product.location = path_to_uri(TEST_GRIB_PRODUCT_PATH)
109110
yield self.product
110111
finally:
111112
self.product.location = original

‎tox.ini

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ python =
1212
3.13: py313
1313

1414
[testenv]
15+
install_command = uv pip install --upgrade {opts} {packages}
1516
deps =
1617
-r{toxinidir}/requirements-dev.txt
17-
pytest
18-
pytest-cov
1918
commands =
2019
pytest --show-capture=no --cov --cov-fail-under=50
2120

@@ -28,6 +27,5 @@ commands =
2827

2928
[testenv:linters]
3029
basepython = python3
31-
skip_install = true
32-
deps = pre-commit
33-
commands = pre-commit run --all-files
30+
commands =
31+
pre-commit run --all-files

0 commit comments

Comments
 (0)
Please sign in to comment.