Skip to content

Commit 3cc6033

Browse files
Migrate package manager to uv (fix #558)
1 parent b8fac65 commit 3cc6033

13 files changed

+1352
-7358
lines changed

.github/workflows/docs.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ name: Docs
33
on:
44
workflow_dispatch:
55
push:
6-
branches: ["master"]
6+
branches: ['master']
77

88
permissions:
99
contents: read
1010
pages: write
1111
id-token: write
1212

1313
concurrency:
14-
group: "pages"
14+
group: 'pages'
1515
cancel-in-progress: false
1616

1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
2020
env:
21-
PYTHON_VERSION: "3.12"
21+
PYTHON_VERSION: '3.12'
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v4
2525
- name: Setup Pages
26-
uses: actions/configure-pages@v4
27-
- uses: actions/setup-python@v5
26+
uses: actions/configure-pages@v5
27+
- uses: astral-sh/setup-uv@v5
2828
with:
29-
python-version: ${{ env.PYTHON_VERSION }}
30-
- name: Install hatch
31-
run: pipx install hatch
29+
python-version: ${{ matrix.python-version }}
30+
enable-cache: true
3231
- run: |
33-
hatch run make docs
32+
uv sync --group dev
33+
make docs
3434
- name: Upload artifact
3535
uses: actions/upload-pages-artifact@v3
3636
with:

.github/workflows/release.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- "v*"
6+
- 'v*'
77

88
permissions:
99
id-token: write
@@ -14,25 +14,24 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
env:
17-
PYTHON_VERSION: "3.12"
17+
PYTHON_VERSION: '3.12'
1818

1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v4
2222

23-
- uses: actions/setup-python@v5
23+
- uses: astral-sh/setup-uv@v5
2424
with:
25-
python-version: ${{ env.PYTHON_VERSION }}
26-
- name: Install hatch
27-
run: pipx install hatch
25+
python-version: ${{ matrix.python-version }}
26+
enable-cache: true
2827

2928
- name: Build
3029
run: |
31-
hatch build
30+
uv build -v
3231
- name: Publish release distributions to PyPI
3332
uses: pypa/gh-action-pypi-publish@release/v1
3433
- name: Release
35-
uses: softprops/action-gh-release@v1
34+
uses: softprops/action-gh-release@v2
3635
with:
3736
files: dist/*
3837
generate_release_notes: true

.github/workflows/test.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test
33
on:
44
push:
55
schedule:
6-
- cron: "0 0 * * 0"
6+
- cron: '0 0 * * 0'
77

88
permissions:
99
id-token: write
@@ -22,17 +22,25 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
25+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2626

2727
steps:
2828
- name: Checkout
2929
uses: actions/checkout@v4
3030

31+
- uses: astral-sh/setup-uv@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
enable-cache: true
35+
# TODO: In the case of Python 3.13, the following error occurs, so install Python using setup-python.
36+
# ../meson.build:44:2: ERROR: Problem encountered: Cannot compile
37+
# `Python.h`. Perhaps you need to install python-dev|python-devel
3138
- uses: actions/setup-python@v5
3239
with:
3340
python-version: ${{ matrix.python-version }}
34-
- name: Install hatch
35-
run: pipx install hatch
41+
if: matrix.python-version == '3.13'
42+
- run: |
43+
make tool
3644
3745
- name: Configure AWS credentials
3846
uses: aws-actions/configure-aws-credentials@v4
@@ -43,5 +51,4 @@ jobs:
4351

4452
- name: Test
4553
run: |
46-
hatch -e test.py${{ matrix.python-version }} run test
47-
hatch -e test.py${{ matrix.python-version }} run test-sqla
54+
make tox

.mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
python = "3.12"

Makefile

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,32 @@
11
.PHONY: fmt
22
fmt:
3-
hatch run fmt
3+
# TODO: https://github.com/astral-sh/uv/issues/5903
4+
uvx ruff check --select I --fix .
5+
uvx ruff format .
46

57
.PHONY: chk
68
chk:
7-
hatch run chk
9+
uvx ruff check .
10+
uvx ruff format --check .
11+
uv run mypy .
812

913
.PHONY: test
1014
test: chk
11-
hatch run test
12-
13-
.PHONY: test-all
14-
test-all: chk
15-
hatch -e test run test
15+
uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/
1616

1717
.PHONY: test-sqla
1818
test-sqla:
19-
hatch run test-sqla
20-
21-
.PHONY: test-sqla-all
22-
test-sqla-all:
23-
hatch -e test run test-sqla
19+
uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/
2420

25-
.PHONY: lock
26-
lock:
27-
rm -rf ./requirements/
28-
hatch env run -- python --version
29-
hatch env run --env test -- python --version
30-
31-
.PHONY: upgrade-lock
32-
upgrade-lock:
33-
rm -rf ./requirements/
34-
PIP_COMPILE_UPGRADE=1 hatch env run -- python --version
35-
PIP_COMPILE_UPGRADE=1 hatch env run --env test -- python --version
21+
.PHONY: tox
22+
tox:
23+
uvx tox run
3624

3725
.PHONY: docs
3826
docs:
39-
cd ./docs && $(MAKE) clean html
27+
cd ./docs && uv run $(MAKE) clean html
28+
29+
.PHONY: tool
30+
tool:
31+
uv tool install ruff
32+
uv tool install tox --with tox-uv --with tox-gh-actions

pyproject.toml

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ pandas = ["pandas>=1.3.0"]
4545
arrow = ["pyarrow>=7.0.0"]
4646
fastparquet = ["fastparquet>=0.4.0"]
4747

48+
[dependency-groups]
49+
dev = [
50+
"sqlalchemy>=1.0.0",
51+
"pandas>=1.3.0",
52+
"numpy>=1.26.0;python_version>=\"3.9\"",
53+
"numpy>=1.24.0,<1.26.0;python_version<\"3.9\"",
54+
"pyarrow>=7.0.0",
55+
"fastparquet>=0.4.0",
56+
"Jinja2>=3.1.0",
57+
"mypy>=0.900",
58+
"pytest>=3.5",
59+
"pytest-cov",
60+
"pytest-xdist",
61+
"pytest-dependency",
62+
"sphinx",
63+
"types-python-dateutil",
64+
]
65+
4866
[build-system]
4967
requires = ["hatchling"]
5068
build-backend = "hatchling.build"
@@ -67,68 +85,12 @@ packages = ["pyathena"]
6785
[tool.hatch.version]
6886
path = "pyathena/__init__.py"
6987

70-
[tool.hatch.env]
71-
requires = [
72-
"hatch-pip-compile"
73-
]
74-
75-
[tool.hatch.envs.default]
76-
python = "3.11"
77-
type = "pip-compile"
78-
lock-filename = "requirements/requirements.txt"
79-
pip-compile-verbose = true
80-
pip-compile-hashes = true
81-
pip-compile-install-args = [
82-
"--no-deps"
83-
]
84-
dependencies = [
85-
"wheel",
86-
"twine",
87-
"sqlalchemy>=1.0.0",
88-
"pandas>=1.3.0",
89-
"numpy>=1.26.0;python_version>=\"3.9\"",
90-
"numpy>=1.24.0,<1.26.0;python_version<\"3.9\"",
91-
"pyarrow>=7.0.0",
92-
"fastparquet>=0.4.0",
93-
"Jinja2>=3.1.0",
94-
"mypy>=0.900",
95-
"pytest>=3.5",
96-
"pytest-cov",
97-
"pytest-xdist",
98-
"pytest-dependency",
99-
"ruff>=0.1.13",
100-
"hatch-pip-compile",
101-
"sphinx",
102-
"types-python-dateutil",
103-
]
104-
105-
[tool.hatch.envs.default.scripts]
106-
test = "pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/"
107-
test-sqla = "pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/"
108-
fmt = [
109-
"ruff check --select I --fix .",
110-
"ruff format ."
111-
]
112-
chk = [
113-
"ruff check .",
114-
"ruff format --check .",
115-
"mypy ."
116-
]
117-
118-
[tool.hatch.envs.test]
119-
template = "default"
120-
lock-filename = "requirements/requirements-{env_name}.txt"
121-
pip-compile-verbose = true
122-
pip-compile-hashes = true
123-
pip-compile-install-args = [
124-
"--no-deps"
125-
]
126-
127-
[[tool.hatch.envs.test.matrix]]
128-
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
129-
13088
[tool.pytest.ini_options]
131-
norecursedirs = ["benchmarks", ".venv"]
89+
norecursedirs = [
90+
"benchmarks",
91+
".venv",
92+
".tox"
93+
]
13294

13395
[tool.sqla_testing]
13496
requirement_cls = "pyathena.sqlalchemy.requirements:Requirements"
@@ -138,6 +100,7 @@ profile_file = "tests/sqlalchemy/profiles.txt"
138100
line-length = 100
139101
exclude = [
140102
".venv",
103+
".tox",
141104
]
142105
target-version = "py38"
143106

@@ -168,4 +131,38 @@ warn_no_return = true
168131
warn_return_any = true
169132
warn_unreachable = true
170133
warn_unused_configs = true
171-
exclude = ["benchmarks.*", "tests.*", ".tox.*", ".venv.*"]
134+
exclude = [
135+
"benchmarks.*",
136+
"tests.*",
137+
".venv.*",
138+
".tox.*",
139+
]
140+
141+
[tool.tox]
142+
legacy_tox_ini = """
143+
[tox]
144+
isolated_build = true
145+
envlist = py{39,310,311,312,313}
146+
147+
[gh-actions]
148+
python =
149+
3.9: py39
150+
3.10: py310
151+
3.11: py311
152+
3.12: py312
153+
3.13: py313
154+
155+
[testenv]
156+
allowlist_externals =
157+
uv
158+
uvx
159+
make
160+
commands =
161+
uv sync --group dev
162+
make test
163+
make test-sqla
164+
passenv =
165+
TOXENV
166+
AWS_*
167+
GITHUB_*
168+
"""

0 commit comments

Comments
 (0)