Skip to content

Commit 800ac86

Browse files
committed
Initial uv migration
1 parent f470cc2 commit 800ac86

File tree

8 files changed

+1955
-2374
lines changed

8 files changed

+1955
-2374
lines changed

.github/file-filters.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ development_files: &development_files
1313
- "development/**"
1414
- "tasks/**"
1515

16-
poetry_files: &poetry_files
16+
uv_files: &uv_files
1717
- "pyproject.toml"
18-
- "poetry.lock"
18+
- "uv.lock"
1919

2020
doc_files: &doc_files
2121
- "docs/**"
2222

2323
python_all: &python_all
2424
- "**/*.py"
25-
- *poetry_files
25+
- *uv_files
2626
- *ci_config
2727
- *coverage_config
2828

.github/workflows/ci.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
helm: ${{ steps.changes.outputs.helm_all }}
4040
python: ${{ steps.changes.outputs.python_all }}
4141
yaml: ${{ steps.changes.outputs.yaml_all }}
42-
poetry_files: ${{ steps.changes.outputs.poetry_files }}
42+
uv_files: ${{ steps.changes.outputs.uv_files }}
4343
github_workflows: ${{ steps.changes.outputs.github_workflows }}
4444
steps:
4545
- name: "Check out repository code"
@@ -138,24 +138,24 @@ jobs:
138138
steps:
139139
- name: "Check out repository code"
140140
uses: "actions/checkout@v4"
141-
- name: Set up Python ${{ matrix.python-version }}
142-
uses: actions/setup-python@v5
141+
- name: "Set up Python ${{ matrix.python-version }}"
142+
uses: "actions/setup-python@v5"
143143
with:
144144
python-version: ${{ matrix.python-version }}
145145
- name: "Setup environment"
146146
run: |
147-
pipx install poetry==1.8.5
148-
poetry config virtualenvs.create true --local
149-
pip install invoke toml codecov
147+
pipx install uv
148+
uv venv
149+
uv pip install invoke toml codecov
150150
- name: "Install Package"
151-
run: "poetry install --all-extras"
151+
run: "uv pip install --all-extras ."
152152
- name: "Mypy Tests"
153-
run: "poetry run mypy --show-error-codes infrahub_sdk/"
153+
run: "uv venv run mypy --show-error-codes infrahub_sdk/"
154154
- name: "Unit Tests"
155-
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
155+
run: "uv venv run pytest --cov infrahub_sdk tests/unit/"
156156
- name: "Upload coverage to Codecov"
157157
run: |
158-
codecov --flags python-${{ matrix.python-version }}
158+
uv venv run codecov --flags python-${{ matrix.python-version }}
159159
env:
160160
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
161161

@@ -165,11 +165,10 @@ jobs:
165165
- name: "Report coverage for pytest-plugin"
166166
if: matrix.python-version == '3.12'
167167
run: |
168-
source $(poetry env info --path)/bin/activate
169-
coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
170-
coverage report -m
171-
coverage xml
172-
codecov --flags python-filler-${{ matrix.python-version }}
168+
uv venv run coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
169+
uv venv run coverage report -m
170+
uv venv run coverage xml
171+
uv venv run codecov --flags python-filler-${{ matrix.python-version }}
173172
env:
174173
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
175174

@@ -197,15 +196,15 @@ jobs:
197196
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
198197
- name: "Setup environment"
199198
run: |
200-
pipx install poetry==1.8.5
201-
poetry config virtualenvs.create true --local
202-
pip install invoke toml codecov
199+
pipx install uv
200+
uv venv
201+
uv pip install invoke toml codecov
203202
- name: "Install Package"
204-
run: "poetry install --all-extras"
203+
run: "uv pip install --all-extras ."
205204
- name: "Integration Tests"
206-
run: "poetry run pytest --cov infrahub_sdk tests/integration/"
205+
run: "uv venv run pytest --cov infrahub_sdk tests/integration/"
207206
- name: "Upload coverage to Codecov"
208207
run: |
209-
codecov --flags integration-tests
208+
uv venv run codecov --flags integration-tests
210209
env:
211210
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/publish-pypi.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,35 @@ jobs:
3838
with:
3939
python-version: "3.12"
4040

41-
- name: "Install Poetry"
42-
uses: "snok/install-poetry@v1"
43-
with:
44-
version: 1.8.5
45-
virtualenvs-create: true
46-
virtualenvs-in-project: true
47-
installer-parallel: true
41+
- name: "Install uv"
42+
run: |
43+
pipx install uv
4844
4945
- name: "Check out repository code"
5046
uses: "actions/checkout@v4"
5147
with:
5248
submodules: true
5349

54-
- name: "Cache poetry venv"
50+
- name: "Cache uv venv"
5551
uses: "actions/cache@v4"
56-
id: "cached-poetry-dependencies"
52+
id: "cached-uv-dependencies"
5753
with:
5854
path: "./python_sdk/.venv"
59-
key: "venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}"
55+
key: "venv-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}"
6056

6157
- name: "Install Dependencies"
62-
run: "poetry install"
63-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
58+
run: "uv pip install --all-extras ."
59+
if: steps.cached-uv-dependencies.outputs.cache-hit != 'true'
6460

6561
- name: "Add PyPI secret"
66-
run: "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
62+
run: "uv pip config set pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
6763

68-
- name: "Poetry build"
69-
run: "poetry build"
64+
- name: "Build package"
65+
run: "uv build"
7066

7167
- name: "show output"
7268
run: "ls -la dist/"
7369

74-
- name: "Poetry push PyPI"
70+
- name: "Publish to PyPI"
7571
if: ${{ inputs.publish }}
76-
run: "poetry publish"
72+
run: "uv publish"

.github/workflows/release.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,24 @@ jobs:
2727
with:
2828
python-version: "3.12"
2929

30-
- name: "Install Poetry"
31-
uses: "snok/install-poetry@v1"
32-
with:
33-
version: 1.8.5
34-
virtualenvs-create: true
35-
virtualenvs-in-project: true
36-
installer-parallel: true
30+
- name: "Install uv"
31+
run: |
32+
pipx install uv
3733
3834
- name: "Setup Python environment"
3935
run: |
40-
poetry config virtualenvs.create true --local
41-
poetry env use 3.12
36+
uv venv
37+
4238
- name: "Install dependencies"
43-
run: "poetry install --no-interaction --no-ansi"
39+
run: "uv pip install --no-deps ."
4440

4541
- name: "Check prerelease type"
4642
id: release
4743
run: |
48-
echo is_prerelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_prerelease))") >> "$GITHUB_OUTPUT"
49-
echo is_devrelease=$(poetry run python -c "from packaging.version import Version; print(int(Version('$(poetry version -s)').is_devrelease))") >> "$GITHUB_OUTPUT"
50-
echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
51-
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+
echo is_prerelease=$(uv venv run python -c "from packaging.version import Version; print(int(Version('$(uv venv run python -c \"import pkg_resources; print(pkg_resources.get_distribution('infrahub-sdk').version)\")').is_prerelease))")") >> "$GITHUB_OUTPUT"
45+
echo is_devrelease=$(uv venv run python -c "from packaging.version import Version; print(int(Version('$(uv venv run python -c \"import pkg_resources; print(pkg_resources.get_distribution('infrahub-sdk').version)\")').is_devrelease))")") >> "$GITHUB_OUTPUT"
46+
echo "version=$(uv venv run python -c \"import pkg_resources; print(pkg_resources.get_distribution('infrahub-sdk').version)\")" >> "$GITHUB_OUTPUT"
47+
echo major_minor_version=$(uv venv run python -c "from packaging.version import Version; print(f\"{Version('$(uv venv run python -c \"import pkg_resources; print(pkg_resources.get_distribution('infrahub-sdk').version)\")').major}.{Version('$(uv venv run python -c \"import pkg_resources; print(pkg_resources.get_distribution('infrahub-sdk').version)\")').minor}\")") >> "$GITHUB_OUTPUT"
5248
echo latest_tag=$(curl -L \
5349
-H "Accept: application/vnd.github+json" \
5450
-H "Authorization: Bearer ${{ github.token }}" \

infrahub_sdk/ctl/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
except ImportError as exc:
66
sys.exit(
77
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`."
8+
"virtual environment and run `uv sync --extras ctl`."
99
)
1010

1111
__all__ = ["app"]

0 commit comments

Comments
 (0)