Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate package manager to uv (fix #558) #568

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ name: Docs
on:
workflow_dispatch:
push:
branches: ["master"]
branches: ['master']

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.12"
PYTHON_VERSION: '3.12'
steps:
- 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
15 changes: 7 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- "v*"
- 'v*'

permissions:
id-token: write
Expand All @@ -14,25 +14,24 @@ jobs:
runs-on: ubuntu-latest

env:
PYTHON_VERSION: "3.12"
PYTHON_VERSION: '3.12'

steps:
- 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
19 changes: 13 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test
on:
push:
schedule:
- cron: "0 0 * * 0"
- cron: '0 0 * * 0'

permissions:
id-token: write
Expand All @@ -22,17 +22,25 @@ 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: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
# TODO: In the case of Python 3.13, the following error occurs, so install Python using setup-python.
# ../meson.build:44:2: ERROR: Problem encountered: Cannot compile
# `Python.h`. Perhaps you need to install python-dev|python-devel
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install hatch
run: pipx install hatch
if: matrix.python-version == '3.13'
- run: |
make tool

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -43,5 +51,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"
41 changes: 17 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
.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
uvx ruff check .
uvx ruff format --check .
uv run mypy .

.PHONY: test
test: chk
hatch run test

.PHONY: test-all
test-all: chk
hatch -e test run test
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
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:
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 tox --with tox-uv --with tox-gh-actions
11 changes: 5 additions & 6 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ Run test

.. code:: bash

$ pip install hatch or pipx install hatch or brew install hatch
$ hatch run test
$ hatch run test-sqla
$ pip install uv or pipx install uv or brew install uv or mise install uv
$ make test
$ make test-sqla

Run test multiple Python versions
---------------------------------

.. code:: bash

$ pip install hatch or pipx install hatch or brew install hatch
$ hatch -e test run test
$ hatch -e test run test-sqla
$ pip install uv or pipx install uv or brew install uv or mise install uv
$ make tox

Code formatting
---------------
Expand Down
121 changes: 59 additions & 62 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ 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",
"mypy>=0.900",
"pytest>=3.5",
"pytest-cov",
"pytest-xdist",
"pytest-dependency",
"sphinx",
"types-python-dateutil",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand All @@ -67,68 +85,12 @@ 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"
Expand All @@ -138,6 +100,7 @@ profile_file = "tests/sqlalchemy/profiles.txt"
line-length = 100
exclude = [
".venv",
".tox",
]
target-version = "py38"

Expand Down Expand Up @@ -168,4 +131,38 @@ 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}

[gh-actions]
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
make test-sqla
passenv =
TOXENV
AWS_*
GITHUB_*
"""
Loading
Loading