Skip to content

Commit 934cfe5

Browse files
feat: migrate from Poetry to UV
- Replace Poetry with UV for dependency management - Update workflows, configs, and documentation - Switch to hatchling build backend - Improve performance and modernize toolchain
1 parent 9aab230 commit 934cfe5

36 files changed

Lines changed: 3010 additions & 5369 deletions

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A clear and concise description of the bug.
1313
## Reproduction Steps
1414
Steps to reproduce the behavior:
1515
1. Install '...'
16-
2. Configure '...'
16+
2. Configure '...'
1717
3. Run code '...'
1818
4. See error
1919

.github/workflows/deploy-docs.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,19 @@ jobs:
2626
uses: actions/setup-python@v5
2727
with:
2828
python-version: '3.13'
29-
cache: 'pip'
3029

31-
- name: Install Poetry
32-
uses: snok/install-poetry@v1
33-
with:
34-
version: 2.0.0
35-
virtualenvs-create: true
36-
virtualenvs-in-project: true
30+
- name: Install UV
31+
uses: astral-sh/setup-uv@v4
3732

38-
- name: Load cached dependencies
39-
id: cached-poetry-dependencies
33+
- name: Cache UV
4034
uses: actions/cache@v4
4135
with:
42-
path: .venv
43-
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
36+
path: ~/.cache/uv
37+
key: uv-${{ runner.os }}-docs-${{ hashFiles('uv.lock') }}
4438

4539
- name: Install dependencies
46-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
4740
run: |
48-
poetry install --with docs
41+
uv sync --extra docs
4942
5043
- name: Configure Git user
5144
run: |
@@ -54,4 +47,4 @@ jobs:
5447
5548
- name: Deploy documentation
5649
run: |
57-
poetry run mkdocs gh-deploy --force
50+
uv run --extra docs mkdocs gh-deploy --force

.github/workflows/lint.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ jobs:
2323
with:
2424
python-version: "3.13"
2525

26-
- name: Install Poetry
27-
run: |
28-
pip install poetry
26+
- name: Install UV
27+
uses: astral-sh/setup-uv@v4
2928

3029
- name: Install dependencies
3130
run: |
32-
poetry install --with dev
31+
uv sync --extra dev
3332
3433
- name: Run Ruff on changed files
3534
run: |
3635
# Filter Python files from changed files and run Ruff
37-
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '\.py$' | xargs -r poetry run ruff check
38-
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '\.py$' | xargs -r poetry run ruff format --check
36+
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '\.py$' | xargs -r uv run ruff check
37+
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '\.py$' | xargs -r uv run ruff format --check

.github/workflows/publish.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ jobs:
1717
with:
1818
python-version: 3.13
1919

20-
- name: Install Poetry
20+
- name: Install UV
21+
uses: astral-sh/setup-uv@v4
22+
23+
- name: Update version in pyproject.toml
2124
run: |
22-
pip install poetry
25+
# Extract version from tag
26+
VERSION=${GITHUB_REF#refs/tags/}
27+
# Update version in pyproject.toml
28+
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
2329
2430
- name: Build and Publish to PyPI
2531
env:
26-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
32+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
2733
run: |
28-
poetry version ${GITHUB_REF#refs/tags/}
29-
poetry build
30-
poetry publish
34+
uv build
35+
uv publish

.github/workflows/tests.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,18 @@ jobs:
1717
- uses: actions/checkout@v4
1818

1919
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323

24-
- name: Install Poetry
25-
uses: snok/install-poetry@v1
26-
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
24+
- name: Install UV
25+
uses: astral-sh/setup-uv@v4
2926

30-
- name: Cache Poetry virtualenv
31-
uses: actions/cache@v3
32-
id: cache
27+
- name: Cache UV
28+
uses: actions/cache@v4
3329
with:
34-
path: .venv
35-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
30+
path: ~/.cache/uv
31+
key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
3632

3733
- name: Install dependencies
3834
run: make install-dev

.pre-commit-config.yaml

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,91 +3,86 @@ repos:
33
hooks:
44
- id: check-added-large-files
55
name: check-added-large-files
6-
entry: poetry run check-added-large-files
6+
entry: uv run check-added-large-files
77
language: system
88
- id: check-yaml
99
name: check-yaml
10-
entry: poetry run check-yaml
10+
entry: uv run check-yaml
1111
types:
1212
- yaml
1313
language: system
1414
- id: check-toml
1515
name: check-toml
16-
entry: poetry run check-toml
16+
entry: uv run check-toml
1717
types:
1818
- toml
1919
language: system
2020
- id: check-json
2121
name: check-json
22-
entry: poetry run check-json
22+
entry: uv run check-json
2323
types:
2424
- json
2525
language: system
2626
- id: pretty-format-json
2727
name: pretty-format-json
28-
entry: poetry run pretty-format-json
28+
entry: uv run pretty-format-json
2929
types:
3030
- json
3131
language: system
3232
- id: end-of-file-fixer
3333
name: end-of-file-fixer
34-
entry: poetry run end-of-file-fixer
34+
entry: uv run end-of-file-fixer
3535
language: system
3636
- id: trailing-whitespace-fixer
3737
name: trailing-whitespace-fixer
38-
entry: poetry run trailing-whitespace-fixer
38+
entry: uv run trailing-whitespace-fixer
3939
language: system
40-
- id: poetry-check
41-
name: poetry-check
42-
entry: poetry check
43-
language: system
44-
pass_filenames: false
45-
- id: poetry-lock
46-
name: poetry-lock
47-
entry: poetry lock
40+
- id: uv-lock
41+
name: uv-lock
42+
entry: uv lock
4843
language: system
4944
pass_filenames: false
5045
stages:
5146
- post-checkout
5247
- post-merge
53-
- id: poetry-install
54-
name: poetry-install
55-
entry: poetry install
48+
- id: uv-sync
49+
name: uv-sync
50+
entry: uv sync --extra dev
5651
language: system
5752
pass_filenames: false
5853
stages:
5954
- post-checkout
6055
- post-merge
6156
- id: codespell
6257
name: codespell
63-
entry: poetry run codespell --toml pyproject.toml
58+
entry: uv run codespell --toml pyproject.toml
6459
files: \.(py|pyi)$
6560
language: system
6661
- id: black
6762
name: black
68-
entry: poetry run black --config pyproject.toml
63+
entry: uv run black --config pyproject.toml
6964
files: \.(py|pyi)$
7065
language: system
7166
exclude: ^(features|scripts)/
7267
- id: ruff
7368
name: ruff
74-
entry: poetry run ruff check --config pyproject.toml --fix
69+
entry: uv run ruff check --config pyproject.toml --fix
7570
files: \.(py|pyi)$
7671
language: system
7772
exclude: ^(features|scripts)/
7873
- id: add-trailing-comma
7974
name: add-trailing-comma
80-
entry: poetry run add-trailing-comma
75+
entry: uv run add-trailing-comma
8176
files: \.(py|pyi)$
8277
language: system
8378
- id: validate-pyproject
8479
name: validate-pyproject
85-
entry: poetry run validate-pyproject pyproject.toml
80+
entry: uv run validate-pyproject pyproject.toml
8681
language: system
8782
pass_filenames: false
8883
- id: mypy
8984
name: mypy
90-
entry: poetry run mypy --config-file pyproject.toml
85+
entry: uv run mypy --config-file pyproject.toml
9186
files: \.(py|pyi)$
9287
language: system
9388
exclude: ^(features|scripts)/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Documentation is crucial for user experience. You can help by:
7575
Before contributing, ensure you have:
7676

7777
- **Python 3.13+**
78-
- **Poetry** (dependency management)
78+
- **UV** (dependency management)
7979
- **Git**
8080
- **make** (for running development commands)
8181

@@ -89,7 +89,7 @@ Before contributing, ensure you have:
8989

9090
2. **Set up the environment**:
9191
```bash
92-
# Set up project pre-requisites
92+
# Set up project pre-requisites (installs UV)
9393
make setup
9494

9595
# Install development dependencies

Makefile

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Variables
2-
PYTHON := poetry run
3-
POETRY := poetry
4-
PRE_COMMIT := poetry run pre-commit
2+
PYTHON := uv run
3+
UV := uv
4+
PRE_COMMIT := uv run pre-commit
55
PROJECT_NAME := archipy
66
PYTHON_FILES := $(PROJECT_NAME) features/steps scripts
77

@@ -23,28 +23,28 @@ help: ## Show this help message
2323
.PHONY: setup
2424
setup: ## Setup project pre-requisites
2525
@echo "${BLUE}Setup project pre-requisites...${NC}"
26-
@echo "${GREEN}Installing poetry (may need your sudo password)...${NC}"
26+
@echo "${GREEN}Installing uv (may need your sudo password)...${NC}"
2727
sudo apt install pipx
28-
pipx install poetry
28+
pipx install uv
2929
pipx ensurepath
30-
poetry completions bash >> ~/.bash_completion
30+
uv generate-shell-completion bash >> ~/.bash_completion
3131

3232
.PHONY: install
3333
install: ## Install project dependencies
3434
@echo "${BLUE}Installing project dependencies...${NC}"
35-
$(POETRY) install
35+
$(UV) sync --extra dev
3636
$(PRE_COMMIT) install
3737

3838
.PHONY: install-dev
39-
install-dev: ## Install project dependencies
40-
@echo "${BLUE}Installing project dependencies...${NC}"
41-
$(POETRY) install --with dev --all-extras
39+
install-dev: ## Install project dependencies with dev extras
40+
@echo "${BLUE}Installing project dependencies with dev extras...${NC}"
41+
$(UV) sync --all-extras
4242
$(PRE_COMMIT) install
4343

4444
.PHONY: update
4545
update: ## Update dependencies to their latest versions
4646
@echo "${BLUE}Updating dependencies...${NC}"
47-
$(POETRY) update
47+
$(UV) lock --upgrade
4848

4949
.PHONY: clean
5050
clean: ## Remove build artifacts and cache directories
@@ -77,45 +77,48 @@ security: ## Run security scan with Bandit
7777
.PHONY: behave
7878
behave: ## Run tests with behave
7979
@echo "${BLUE}Running tests...${NC}"
80-
$(PYTHON) behave
80+
$(UV) run --extra behave behave
81+
82+
.PHONY: test
83+
test: behave ## Run tests (alias for behave)
8184

8285
.PHONY: build
8386
build: clean ## Build project distribution
8487
@echo "${BLUE}Building project distribution...${NC}"
85-
$(POETRY) build
88+
$(UV) build
8689

8790
.PHONY: version
8891
version: ## Display current version
8992
@echo "${BLUE}Current version:${NC}"
90-
@$(POETRY) version
91-
@echo "${YELLOW}Current tag(Fetching...):${NC}"
92-
@git fetch && git describe --tags --abbrev=0
93+
@$(UV) run python -c "import tomllib; print(f\"archipy {tomllib.load(open('pyproject.toml', 'rb'))['project']['version']}\")"
94+
@echo "${YELLOW}Current tag:${NC}"
95+
@git describe --tags --abbrev=0 2>/dev/null || echo "No tags found"
9396

9497
.PHONY: bump-patch
9598
bump-patch: ## Bump patch version
9699
@echo "${BLUE}Bumping patch version...${NC}"
97100
@if [ -n "$(message)" ]; then \
98-
$(PYTHON) python scripts/bump_version.py patch -m "$(message)"; \
101+
$(UV) run python scripts/bump_version.py patch -m "$(message)"; \
99102
else \
100-
$(PYTHON) python scripts/bump_version.py patch -m "$$(git log -1 --pretty=%s)"; \
103+
$(UV) run python scripts/bump_version.py patch -m "$$(git log -1 --pretty=%s)"; \
101104
fi
102105

103106
.PHONY: bump-minor
104107
bump-minor: ## Bump minor version
105108
@echo "${BLUE}Bumping minor version...${NC}"
106109
@if [ -n "$(message)" ]; then \
107-
$(PYTHON) python scripts/bump_version.py minor -m "$(message)"; \
110+
$(UV) run python scripts/bump_version.py minor -m "$(message)"; \
108111
else \
109-
$(PYTHON) python scripts/bump_version.py minor -m "$$(git log -1 --pretty=%s)"; \
112+
$(UV) run python scripts/bump_version.py minor -m "$$(git log -1 --pretty=%s)"; \
110113
fi
111114

112115
.PHONY: bump-major
113116
bump-major: ## Bump major version
114117
@echo "${BLUE}Bumping major version...${NC}"
115118
@if [ -n "$(message)" ]; then \
116-
$(PYTHON) python scripts/bump_version.py major -m "$(message)"; \
119+
$(UV) run python scripts/bump_version.py major -m "$(message)"; \
117120
else \
118-
$(PYTHON) python scripts/bump_version.py major -m "$$(git log -1 --pretty=%s)"; \
121+
$(UV) run python scripts/bump_version.py major -m "$$(git log -1 --pretty=%s)"; \
119122
fi
120123

121124
.PHONY: docker-build
@@ -134,7 +137,7 @@ pre-commit: ## Run pre-commit hooks
134137
$(PRE_COMMIT) run --all-files
135138

136139
.PHONY: check
137-
check: lint security test ## Run all checks (linting, security, and tests)
140+
check: lint security behave ## Run all checks (linting, security, and tests)
138141

139142
.PHONY: ci
140143
ci: ## Run CI pipeline locally
@@ -143,22 +146,22 @@ ci: ## Run CI pipeline locally
143146
$(MAKE) install
144147
$(MAKE) lint
145148
$(MAKE) security
146-
$(MAKE) test
149+
$(MAKE) behave
147150
$(MAKE) build
148151

149152
.PHONY: docs-serve
150153
docs-serve: ## Serve MkDocs documentation locally
151154
@echo "${BLUE}Serving documentation...${NC}"
152-
$(POETRY) run mkdocs serve
155+
$(UV) run --extra docs mkdocs serve
153156

154157
.PHONY: docs-build
155158
docs-build: ## Build MkDocs documentation
156159
@echo "${BLUE}Building documentation...${NC}"
157-
$(POETRY) run mkdocs build
160+
$(UV) run --extra docs mkdocs build
158161

159162
.PHONY: docs-deploy
160163
docs-deploy: ## Deploy MkDocs to GitHub Pages
161164
@echo "${BLUE}Deploying documentation...${NC}"
162-
$(POETRY) run mkdocs gh-deploy --force
165+
$(UV) run --extra docs mkdocs gh-deploy --force
163166

164167
.DEFAULT_GOAL := help

0 commit comments

Comments
 (0)