Skip to content

Commit

Permalink
Use uv and uv-pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Apr 15, 2024
1 parent 90a6592 commit 9179e4a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 150 deletions.
30 changes: 14 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: pretty-format-json
args:
Expand All @@ -20,7 +20,7 @@ repos:
files: ^docs/.*\.rst$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.7
hooks:
- id: ruff
args:
Expand All @@ -46,29 +46,27 @@ repos:
args:
- "a3m"

- repo: https://github.com/jazzband/pip-tools
rev: 7.4.1
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.1.31
hooks:
- id: pip-compile
args:
- "--python-version=3.12"
- "--output-file=requirements.txt"
- "pyproject.toml"
files: |
(?x)^(
setup.cfg|
pyproject.toml|
requirements.txt
)$
- id: pip-compile
args:
- "--output-file=requirements.txt"
- "--python-version=3.12"
- "--output-file=requirements-dev.txt"
- "pyproject.toml"

- repo: https://github.com/jazzband/pip-tools
rev: 7.4.1
hooks:
- id: pip-compile
- "--extra=dev"
files: |
(?x)^(
setup.cfg|
pyproject.toml|
requirements-dev.txt
)$
args:
- "--output-file=requirements-dev.txt"
- "--extra=dev"
- "pyproject.toml"
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ A3M_PIPELINE_DATA ?= $(CURDIR)/hack/compose-volume
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)

PYTHON_VERSION = $(shell cat .python-version | awk -F '.' '{print $$1 "." $$2}')

define compose
docker compose -f docker-compose.yml $(1)
endef
Expand Down Expand Up @@ -70,17 +72,17 @@ restart: ## Restart services

.PHONY: pip-compile
pip-compile: ## Compile pip requirements
pip-compile --output-file=requirements.txt pyproject.toml
pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
uv pip compile --python-version=$(PYTHON_VERSION) --output-file=requirements.txt pyproject.toml
uv pip compile --python-version=$(PYTHON_VERSION) --output-file=requirements-dev.txt pyproject.toml --extra=dev

.PHONY: pip-upgrade
pip-upgrade: ## Upgrade pip requirements
pip-compile --upgrade --output-file=requirements.txt pyproject.toml
pip-compile --upgrade --extra=dev --output-file=requirements-dev.txt pyproject.toml
uv pip compile --upgrade --python-version=$(PYTHON_VERSION) --output-file=requirements.txt pyproject.toml
uv pip compile --upgrade --python-version=$(PYTHON_VERSION) --output-file=requirements-dev.txt pyproject.toml --extra=dev

.PHONY: pip-sync
pip-sync: ## Ensures that the local venv mirrors requirements-dev.txt.
pip-sync requirements-dev.txt
uv pip sync requirements-dev.txt

.PHONY: db
db:
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Python dependencies
The requirements are listed in ``/pyproject.toml``. The constraints are relaxed
with the purpose of allowing a3m to be used as a library.

We use `pip-tools` which pins the requirements in ``requirements.txt`` and
We use `uv` which pins the requirements in ``requirements.txt`` and
``requirements-dev.txt`` for our Docker image. We provide a few helpers:

* ``make pip-compile`` generates the requirements with the latest versions of
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ dev = [
"pytest-env",
"pytest-mock",
"coverage",
"pip-tools",
"grpcio-tools",
"mypy",
"tox",
Expand Down
Loading

0 comments on commit 9179e4a

Please sign in to comment.