Skip to content

Commit

Permalink
Migrate package manager to uv (fix #558)
Browse files Browse the repository at this point in the history
  • Loading branch information
laughingman7743 committed Dec 28, 2024
1 parent cf67b76 commit bb27648
Show file tree
Hide file tree
Showing 7 changed files with 1,301 additions and 104 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- uses: actions/setup-python@v5
uses: actions/configure-pages@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install hatch
run: pipx install hatch
python-version: ${{ matrix.python-version }}
enable-cache: true
- run: |
hatch run make docs
uv sync --group dev
make docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

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

- name: Build
run: |
hatch build
uv build -v
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
12 changes: 6 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install hatch
run: pipx install hatch
enable-cache: true
- run: |
make tool
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -43,5 +44,4 @@ jobs:

- name: Test
run: |
hatch -e test.py${{ matrix.python-version }} run test
hatch -e test.py${{ matrix.python-version }} run test-sqla
make tox
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
python = "3.12"
46 changes: 22 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
.PHONY: fmt
fmt:
hatch run fmt
# TODO: https://github.com/astral-sh/uv/issues/5903
uvx ruff check --select I --fix .
uvx ruff format .

.PHONY: chk
chk:
hatch run chk
# TODO: https://github.com/astral-sh/uv/issues/5903
uvx ruff check .
uvx ruff format --check .
uvx mypy .

.PHONY: test
test: chk
hatch run test

.PHONY: test-all
test-all: chk
hatch -e test run test
# TODO: https://github.com/astral-sh/uv/issues/5903
uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/

.PHONY: test-sqla
test-sqla:
hatch run test-sqla

.PHONY: test-sqla-all
test-sqla-all:
hatch -e test run test-sqla
# TODO: https://github.com/astral-sh/uv/issues/5903
uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/

.PHONY: lock
lock:
rm -rf ./requirements/
hatch env run -- python --version
hatch env run --env test -- python --version

.PHONY: upgrade-lock
upgrade-lock:
rm -rf ./requirements/
PIP_COMPILE_UPGRADE=1 hatch env run -- python --version
PIP_COMPILE_UPGRADE=1 hatch env run --env test -- python --version
.PHONY: tox
tox:
# TODO: https://github.com/astral-sh/uv/issues/5903
uvx tox run

.PHONY: docs
docs:
cd ./docs && $(MAKE) clean html
cd ./docs && uv run $(MAKE) clean html

.PHONY: tool
tool:
uv tool install ruff
uv tool install mypy
uv tool install tox --with tox-uv --with tox-gh
127 changes: 65 additions & 62 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ pandas = ["pandas>=1.3.0"]
arrow = ["pyarrow>=7.0.0"]
fastparquet = ["fastparquet>=0.4.0"]

[dependency-groups]
dev = [
"sqlalchemy>=1.0.0",
"pandas>=1.3.0",
"numpy>=1.26.0;python_version>=\"3.9\"",
"numpy>=1.24.0,<1.26.0;python_version<\"3.9\"",
"pyarrow>=7.0.0",
"fastparquet>=0.4.0",
"Jinja2>=3.1.0",
"pytest>=3.5",
"pytest-cov",
"pytest-xdist",
"pytest-dependency",
"sphinx",
"types-python-dateutil",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand All @@ -67,77 +84,25 @@ packages = ["pyathena"]
[tool.hatch.version]
path = "pyathena/__init__.py"

[tool.hatch.env]
requires = [
"hatch-pip-compile"
]

[tool.hatch.envs.default]
python = "3.11"
type = "pip-compile"
lock-filename = "requirements/requirements.txt"
pip-compile-verbose = true
pip-compile-hashes = true
pip-compile-install-args = [
"--no-deps"
]
dependencies = [
"wheel",
"twine",
"sqlalchemy>=1.0.0",
"pandas>=1.3.0",
"numpy>=1.26.0;python_version>=\"3.9\"",
"numpy>=1.24.0,<1.26.0;python_version<\"3.9\"",
"pyarrow>=7.0.0",
"fastparquet>=0.4.0",
"Jinja2>=3.1.0",
"mypy>=0.900",
"pytest>=3.5",
"pytest-cov",
"pytest-xdist",
"pytest-dependency",
"ruff>=0.1.13",
"hatch-pip-compile",
"sphinx",
"types-python-dateutil",
]

[tool.hatch.envs.default.scripts]
test = "pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/"
test-sqla = "pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/"
fmt = [
"ruff check --select I --fix .",
"ruff format ."
]
chk = [
"ruff check .",
"ruff format --check .",
"mypy ."
]

[tool.hatch.envs.test]
template = "default"
lock-filename = "requirements/requirements-{env_name}.txt"
pip-compile-verbose = true
pip-compile-hashes = true
pip-compile-install-args = [
"--no-deps"
]

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]

[tool.pytest.ini_options]
norecursedirs = ["benchmarks", ".venv"]
norecursedirs = [
"benchmarks",
".venv",
".tox"
]

[tool.sqla_testing]
requirement_cls = "pyathena.sqlalchemy.requirements:Requirements"
profile_file = "tests/sqlalchemy/profiles.txt"

[tool.uv]
python-preference = "managed"

[tool.ruff]
line-length = 100
exclude = [
".venv",
".tox",
]
target-version = "py38"

Expand Down Expand Up @@ -168,4 +133,42 @@ warn_no_return = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
exclude = ["benchmarks.*", "tests.*", ".tox.*", ".venv.*"]
exclude = [
"benchmarks.*",
"tests.*",
".venv.*",
".tox.*",
]

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py{39,310,311,312,313},py{39,310,311,312,313}-sqla
[gh]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
[testenv]
allowlist_externals =
uv
uvx
make
commands =
uv sync --group dev
make test
passenv =
TOXENV
AWS_*
GITHUB_*
[testenv:py{39,310,311,312,313}-sqla]
commands =
uv sync --group dev
make test-sqla
"""
Loading

0 comments on commit bb27648

Please sign in to comment.