Skip to content

Commit 1f6446f

Browse files
authored
Add multi-python version support with tox (#168)
* first attempt at tox setup * multipython testing setup * revert lint part of pull_requests.yaml
1 parent 2e402e4 commit 1f6446f

File tree

7 files changed

+231
-1488
lines changed

7 files changed

+231
-1488
lines changed

.github/workflows/pull-request.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,20 @@ jobs:
2929

3030
tests:
3131
runs-on: ubuntu-latest
32-
strategy:
33-
matrix:
34-
python-version: ["3.13"]
3532
steps:
3633
- uses: actions/checkout@v4
3734
- name: Install uv
3835
uses: astral-sh/setup-uv@v6
3936
with:
4037
enable-cache: true
4138
cache-dependency-glob: "uv.lock"
42-
- name: Set up Python ${{ matrix.python-version }}
43-
run: uv python install ${{ matrix.python-version }}
39+
- name: Install Python versions
40+
run: uv python install 3.11 3.12 3.13
4441
- name: Install dependencies
4542
run: uv sync --extra dev
46-
- name: Unit Tests
47-
run: make test-unit
48-
- name: End to End Tests
43+
- name: Run tests with tox
44+
run: uv run tox
45+
- name: Run E2E tests (Python 3.13)
4946
env:
5047
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
51-
run: make test-e2e
48+
run: uv run --python 3.13 --extra dev python -m pytest tests/e2e -v

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ venv/
99
tmp/
1010
.vscode/
1111
build/
12-
.DS_Store
12+
.DS_Store
13+
.tox/

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ install-dev:
1010
uv sync --extra dev
1111

1212
clean:
13-
rm -rf __pycache__
13+
rm -rf __pycache__ .tox dist
1414

1515
fmt:
1616
uv run ruff format
@@ -36,3 +36,6 @@ test-e2e:
3636
uv run python -m pytest tests/e2e
3737

3838
test-all: test-unit test-e2e
39+
40+
test-tox:
41+
uv run tox

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
2-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1+
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
2+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
33
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![Build](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml/badge.svg)](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml)
55

@@ -155,10 +155,10 @@ uv sync --extra dev
155155
## Development Commands
156156
```shell
157157
# Format code
158-
uv run black ./
158+
uv run ruff format
159159
160160
# Lint code
161-
uv run pylint dune_client/
161+
uv run ruff check
162162
163163
# Type checking
164164
uv run mypy dune_client/ --strict
@@ -168,6 +168,22 @@ uv run python -m pytest tests/unit # Unit tests
168168
uv run python -m pytest tests/e2e # E2E tests (requires DUNE_API_KEY)
169169
```
170170
171+
## Multi-Python Testing
172+
173+
This project supports Python 3.11, 3.12, and 3.13. You can test across all versions using tox with uv:
174+
175+
```shell
176+
# Test all Python versions with tox
177+
uv run tox
178+
# or
179+
make test-tox
180+
181+
# Test specific Python versions
182+
uv run tox -e py311
183+
uv run tox -e py312
184+
uv run tox -e py313
185+
```
186+
171187
## Makefile Shortcuts
172188
173189
### Installation
@@ -187,8 +203,9 @@ can also be run individually with `fmt`, `lint` and `types` respectively.
187203
```shell
188204
make test-unit # Unit tests
189205
make test-e2e # Requires valid `DUNE_API_KEY`
206+
make test-all # Both unit and e2e tests
207+
make test-tox # Multi-Python testing (py311, py312, py313)
190208
```
191-
can also run both with `make test-all`
192209
193210
## Deployment
194211

pyproject.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,26 @@ build-backend = "hatchling.build"
66
name = "dune_client"
77
description = "A simple framework for interacting with Dune Analytics official API service."
88
readme = "README.md"
9-
requires-python = ">=3.8"
9+
requires-python = ">=3.11"
1010
license = {text = "Apache License Version 2.0"}
1111
authors = [
1212
{name = "Benjamin H. Smith & Dune Analytics", email = "ben@cow.fi"},
1313
]
1414
classifiers = [
1515
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
"Programming Language :: Python :: 3.13",
1619
"License :: OSI Approved :: Apache Software License",
1720
"Operating System :: OS Independent",
1821
]
1922
dependencies = [
2023
"aiohttp~=3.10.0",
2124
"dataclasses-json~=0.6.4",
22-
"types-python-dateutil>=2.8.19.14",
23-
"types-PyYAML>=6.0.12.11",
24-
"types-requests>=2.28.0",
25-
"types-setuptools>=68.2.0.0",
2625
"python-dateutil~=2.8.2",
2726
"requests~=2.31.0",
2827
"ndjson~=0.3.1",
2928
"Deprecated~=1.2.14",
30-
"types-Deprecated>=1.2.9.3",
3129
]
3230
dynamic = ["version"]
3331

@@ -38,12 +36,19 @@ Issues = "https://github.com/duneanalytics/dune-client/issues"
3836

3937
[project.optional-dependencies]
4038
dev = [
39+
"pytest>=7.4.1",
4140
"ruff>=0.13.1",
41+
"mypy>=1.5.1",
42+
"tox>=4.0.0",
43+
"tox-uv>=1.28.0",
44+
# Type stubs
45+
"types-python-dateutil>=2.8.19.14",
46+
"types-requests>=2.28.0",
47+
"types-Deprecated>=1.2.9.3",
48+
# Optional features
4249
"pandas>=1.0.0",
4350
"pandas-stubs>=1.0.0",
44-
"pytest>=7.4.1",
4551
"python-dotenv>=1.0.0",
46-
"mypy>=1.5.1",
4752
"aiounittest>=1.4.2",
4853
"colorlover>=0.3.0",
4954
"plotly>=5.9.0",
@@ -55,10 +60,6 @@ source = "vcs"
5560
[tool.hatch.build.targets.wheel]
5661
packages = ["dune_client"]
5762

58-
[dependency-groups]
59-
dev = [
60-
"pyyaml>=6.0.2",
61-
]
6263

6364
[tool.ruff]
6465
# Increase the maximum line length to 100 characters.

tox.ini

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[tox]
2+
envlist = py311,py312,py313
3+
isolated_build = true
4+
skip_missing_interpreters = true
5+
min_version = 4.0
6+
7+
[testenv]
8+
description = Run tests with pytest
9+
package = wheel
10+
wheel_build_env = .pkg
11+
runner = uv-venv-runner
12+
extras = dev
13+
commands =
14+
python -m pytest tests/unit -v
15+
16+
[testenv:py311]
17+
description = Run tests with Python 3.11
18+
basepython = python3.11
19+
20+
[testenv:py312]
21+
description = Run tests with Python 3.12
22+
basepython = python3.12
23+
24+
[testenv:py313]
25+
description = Run tests with Python 3.13
26+
basepython = python3.13

0 commit comments

Comments
 (0)