Skip to content

Commit 55f17e5

Browse files
committed
Convert project to UV
1 parent 7d3878c commit 55f17e5

File tree

13 files changed

+3756
-4032
lines changed

13 files changed

+3756
-4032
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
!contains(needs.*.result, 'failure') &&
130130
!contains(needs.*.result, 'cancelled') &&
131131
needs.files-changed.outputs.documentation == 'true'
132-
needs: ["files-changed", "yaml-lint", "python-lint"]
132+
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
133133
runs-on: "ubuntu-22.04"
134134
timeout-minutes: 5
135135
steps:
@@ -145,10 +145,18 @@ jobs:
145145
cache-dependency-path: docs/package-lock.json
146146
- name: "Install dependencies"
147147
run: npm install
148-
- name: "Setup Python environment"
149-
run: "pip install invoke"
148+
- name: Set up Python
149+
uses: actions/setup-python@v6
150+
with:
151+
python-version: "3.12"
152+
- name: Install UV
153+
uses: astral-sh/setup-uv@v4
154+
with:
155+
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
156+
- name: Install dependencies
157+
run: uv sync --all-groups --all-extras
150158
- name: "Build docs website"
151-
run: "invoke docs"
159+
run: "uv run invoke docs"
152160

153161
validate-generated-documentation:
154162
if: |
@@ -168,17 +176,14 @@ jobs:
168176
uses: actions/setup-python@v6
169177
with:
170178
python-version: "3.12"
171-
- name: "Setup Python environment"
172-
run: |
173-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
174-
poetry config virtualenvs.create true --local
175-
poetry env use 3.12
176-
- name: "Install dependencies"
177-
run: "poetry install --no-interaction --no-ansi --extras ctl"
178-
- name: "Setup environment"
179-
run: "poetry run pip install invoke"
180-
- name: "Validate generated documentation"
181-
run: "poetry run invoke docs-validate"
179+
- name: Install UV
180+
uses: astral-sh/setup-uv@v4
181+
with:
182+
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
183+
- name: Install dependencies
184+
run: uv sync --all-groups --all-extras
185+
- name: Validate generated documentation
186+
run: uv run invoke docs-validate
182187

183188
validate-documentation-style:
184189
if: |
@@ -232,24 +237,19 @@ jobs:
232237
uses: actions/setup-python@v6
233238
with:
234239
python-version: ${{ matrix.python-version }}
235-
- name: "Setup environment"
236-
run: |
237-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }} --python python${{ matrix.python-version }}
238-
poetry config virtualenvs.create true --local
239-
pip install invoke codecov
240-
- name: "Install tomli for Python < 3.11"
241-
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
242-
run: |
243-
pip install tomli
244-
- name: "Install Package"
245-
run: "poetry install --all-extras"
246-
- name: "Mypy Tests"
247-
run: "poetry run mypy --show-error-codes infrahub_sdk/"
248-
- name: "Unit Tests"
249-
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
240+
- name: Install UV
241+
uses: astral-sh/setup-uv@v4
242+
with:
243+
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
244+
- name: Install dependencies
245+
run: uv sync --all-groups --all-extras
246+
- name: Mypy Tests
247+
run: uv run mypy --show-error-codes infrahub_sdk/
248+
- name: Unit Tests
249+
run: uv run pytest --cov infrahub_sdk tests/unit/
250250
- name: "Upload coverage to Codecov"
251251
run: |
252-
codecov --flags python-${{ matrix.python-version }}
252+
uv run codecov --flags python-${{ matrix.python-version }}
253253
env:
254254
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
255255

@@ -259,11 +259,10 @@ jobs:
259259
- name: "Report coverage for pytest-plugin"
260260
if: matrix.python-version == '3.12'
261261
run: |
262-
source $(poetry env info --path)/bin/activate
263-
coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
264-
coverage report -m
265-
coverage xml
266-
codecov --flags python-filler-${{ matrix.python-version }}
262+
uv run coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
263+
uv run coverage report -m
264+
uv run coverage xml
265+
uv run codecov --flags python-filler-${{ matrix.python-version }}
267266
env:
268267
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
269268

@@ -289,19 +288,17 @@ jobs:
289288
run: |
290289
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
291290
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
292-
- name: "Setup environment"
293-
run: |
294-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
295-
poetry config virtualenvs.create true --local
296-
pip install invoke codecov
297-
- name: "Install Package"
298-
run: "poetry install --all-extras"
299-
- name: "Integration Tests"
300-
run: |
301-
poetry run pytest --cov infrahub_sdk tests/integration/
291+
- name: Install UV
292+
uses: astral-sh/setup-uv@v4
293+
with:
294+
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
295+
- name: Install dependencies
296+
run: uv sync --all-groups --all-extras
297+
- name: Integration Tests
298+
run: uv run pytest --cov infrahub_sdk tests/integration/
302299
- name: "Upload coverage to Codecov"
303300
run: |
304-
codecov --flags integration-tests
301+
uv run codecov --flags integration-tests
305302
env:
306303
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
307304

.github/workflows/define-versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ name: "Define versions"
44
on:
55
workflow_call:
66
outputs:
7-
POETRY_VERSION:
8-
value: "2.1.3"
7+
UV_VERSION:
8+
value: "0.9.8"
99

1010
jobs:
1111
prepare:

.github/workflows/publish-pypi.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,36 @@ jobs:
4141
with:
4242
python-version: "3.12"
4343

44-
- name: "Install Poetry"
45-
uses: "snok/install-poetry@v1"
44+
- name: Install UV
45+
uses: astral-sh/setup-uv@v4
4646
with:
47-
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
48-
virtualenvs-create: true
49-
virtualenvs-in-project: true
50-
installer-parallel: true
47+
version: ${{ needs.prepare-environment.outputs.UV_VERSION }}
5148

52-
- name: "Check out repository code"
49+
- name: Check out repository code
5350
uses: "actions/checkout@v5"
5451
with:
5552
submodules: true
5653

57-
- name: "Cache poetry venv"
54+
- name: Cache UV dependencies
5855
uses: "actions/cache@v4"
59-
id: "cached-poetry-dependencies"
56+
id: "cached-uv-dependencies"
6057
with:
61-
path: "./python_sdk/.venv"
62-
key: "venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}"
58+
path: ".venv"
59+
key: "venv-${{ runner.os }}-${{ hashFiles('uv.lock') }}"
6360

64-
- name: "Install Dependencies"
65-
run: "poetry install"
66-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
61+
- name: Install Dependencies
62+
run: uv sync --all-groups --all-extras
63+
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'
6764

68-
- name: "Add PyPI secret"
69-
run: "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
65+
- name: Add PyPI secret
66+
run: uv config token pypi ${{ secrets.PYPI_TOKEN }}
7067

71-
- name: "Poetry build"
72-
run: "poetry build"
68+
- name: Build package
69+
run: uv build
7370

74-
- name: "show output"
75-
run: "ls -la dist/"
71+
- name: Show output
72+
run: ls -la dist/
7673

77-
- name: "Poetry push PyPI"
74+
- name: Publish to PyPI
7875
if: ${{ inputs.publish }}
79-
run: "poetry publish"
76+
run: uv publish

.github/workflows/release.yml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,22 @@ jobs:
3030
with:
3131
python-version: "3.12"
3232

33-
- name: "Install Poetry"
34-
uses: "snok/install-poetry@v1"
33+
- name: Install UV
34+
uses: astral-sh/setup-uv@v4
3535
with:
36-
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
37-
virtualenvs-create: true
38-
virtualenvs-in-project: true
39-
installer-parallel: true
36+
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
4037

41-
- name: "Setup Python environment"
42-
run: |
43-
poetry config virtualenvs.create true --local
44-
poetry env use 3.12
45-
- name: "Install dependencies"
46-
run: "poetry install --no-interaction --no-ansi"
38+
- name: Install dependencies
39+
run: uv sync --all-groups --all-extras
4740

48-
- name: "Check prerelease type"
41+
- name: Check prerelease type
4942
id: release
5043
run: |
51-
echo is_prerelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_prerelease))") >> "$GITHUB_OUTPUT"
52-
echo is_devrelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_devrelease))") >> "$GITHUB_OUTPUT"
53-
echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
54-
echo major_minor_version=$(poetry run python -c "from packaging.version import Version; print(f\"{Version('$(poetry version -s)').major}.{Version('$(poetry version -s)').minor}\")") >> "$GITHUB_OUTPUT"
44+
VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
45+
echo is_prerelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_prerelease))") >> "$GITHUB_OUTPUT"
46+
echo is_devrelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_devrelease))") >> "$GITHUB_OUTPUT"
47+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
48+
echo major_minor_version=$(uv run python -c "from packaging.version import Version; v = Version('$VERSION'); print(f'{v.major}.{v.minor}')") >> "$GITHUB_OUTPUT"
5549
echo latest_tag=$(curl -L \
5650
-H "Accept: application/vnd.github+json" \
5751
-H "Authorization: Bearer ${{ github.token }}" \
@@ -60,10 +54,14 @@ jobs:
6054
| jq -r '.tag_name') >> "$GITHUB_OUTPUT"
6155
6256
- name: Check tag version
63-
if: github.event.release.tag_name != format('v{0}', steps.release.outputs.version)
6457
run: |
65-
echo "Tag version does not match python project version"
66-
exit 1
58+
EXPECTED_TAG="v${{ steps.release.outputs.version }}"
59+
if [ "${{ github.event.release.tag_name }}" != "$EXPECTED_TAG" ]; then
60+
echo "Tag version does not match python project version"
61+
echo "Expected: $EXPECTED_TAG"
62+
echo "Got: ${{ github.event.release.tag_name }}"
63+
exit 1
64+
fi
6765
6866
- name: Check prerelease and project version
6967
if: github.event.release.prerelease == true && steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ script.py
88
.vscode/settings.json
99
.DS_Store
1010
.python-version
11+
.venv/
12+
.venv
1113
.ruff_cache
1214
**/.ruff_cache
1315
**/.idea/**

CLAUDE.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,45 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
```bash
1010
# Install dependencies
11-
poetry install --with dev --all-extras
11+
uv sync --all-groups --all-extras
12+
13+
# Install specific groups
14+
uv sync --group tests # Testing dependencies only
15+
uv sync --group lint # Linting dependencies only
16+
uv sync --extra ctl # CLI dependencies only
17+
uv sync --all-groups --all-extras # All optional dependencies
1218

1319
# Format code
14-
poetry run invoke format
20+
uv run invoke format
1521

1622
# Run linting (ruff + mypy + yamllint + markdownlint)
17-
poetry run invoke lint
23+
uv run invoke lint
1824

1925
# Run unit tests with coverage
20-
poetry run pytest --cov infrahub_sdk tests/unit/
26+
uv run pytest --cov infrahub_sdk tests/unit/
2127

2228
# Run integration tests
23-
poetry run pytest tests/integration/
29+
uv run pytest tests/integration/
2430

2531
# Generate documentation
26-
poetry run invoke docs
32+
uv run invoke docs
2733

2834
# Validate documentation
29-
poetry run invoke docs-validate
35+
uv run invoke docs-validate
3036
```
3137

3238
### Testing Specific Components
3339

3440
```bash
3541
# Run tests for specific modules
36-
poetry run pytest tests/unit/test_client.py
37-
poetry run pytest tests/unit/test_node.py
42+
uv run pytest tests/unit/test_client.py
43+
uv run pytest tests/unit/test_node.py
3844

3945
# Run with verbose output
40-
poetry run pytest -v tests/unit/
46+
uv run pytest -v tests/unit/
4147

4248
# Run with parallel execution
43-
poetry run pytest -n 4 tests/unit/
49+
uv run pytest -n 4 tests/unit/
4450
```
4551

4652
## Architecture Overview
@@ -148,7 +154,7 @@ CLI commands are auto-documented and organized in `infrahub_sdk/ctl/`.
148154

149155
```bash
150156
# Generate all docs
151-
poetry run invoke docs
157+
uv run invoke docs
152158

153159
# Start development server (requires Node.js)
154160
cd docs && npm start
@@ -168,7 +174,7 @@ cd docs && npm start
168174

169175
GitHub Actions workflow runs:
170176

171-
1. Multi-version Python testing (3.9-3.13)
177+
1. Multi-version Python testing (3.10-3.13)
172178
2. Comprehensive linting pipeline
173179
3. Documentation generation and validation
174180
4. Integration testing with Infrahub containers

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,18 @@ Installs infrahub-sdk together with all the extras.
5656
```bash
5757
pip install 'infrahub-sdk[all]'
5858
```
59+
60+
### Development setup with UV
61+
62+
If you're developing the SDK and using UV for dependency management, you can install specific dependency groups:
63+
64+
```bash
65+
# Install development dependencies
66+
uv sync --all-groups --all-extras
67+
68+
# Install specific groups
69+
uv sync --group tests # Testing dependencies only
70+
uv sync --group lint # Linting dependencies only
71+
uv sync --group ctl # CLI dependencies only
72+
uv sync --all-groups --all-extras # All optional dependencies
73+
```

docs/docs/python-sdk/guides/client.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you prefer to jump right in, check out the ["Hello World" example](#hello-wor
1717
## Prerequisites
1818

1919
- Python 3.9 or higher
20-
- Infrahub SDK installed (`pip install infrahub-sdk` or `poetry add infrahub-sdk`)
20+
- Infrahub SDK installed (`pip install infrahub-sdk` or `uv add infrahub-sdk`)
2121
- Access to an Infrahub instance (local or remote)
2222
- Valid credentials (API token or username/password) if authentication is required
2323

infrahub_sdk/ctl/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from .cli_commands import app
55
except ImportError as exc:
66
sys.exit(
7-
f"Module {exc.name} is not available, install the 'ctl' extra of the infrahub-sdk package, `pip install 'infrahub-sdk[ctl]'` or enable the "
8-
"Poetry shell and run `poetry install --extras ctl`."
7+
f"Module {exc.name} is not available, install the 'ctl' extra of the infrahub-sdk package, "
8+
f"`pip install 'infrahub-sdk[ctl]'` or run `uv sync --extra ctl`."
99
)
1010

1111
__all__ = ["app"]

0 commit comments

Comments
 (0)