Skip to content

Commit 59c301d

Browse files
authored
Migrate from poetry to uv
2 parents edac40f + 7e47088 commit 59c301d

42 files changed

Lines changed: 3136 additions & 2304 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yaml

Lines changed: 27 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,16 @@ jobs:
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Setup python
16-
uses: actions/setup-python@v1
17-
with:
18-
python-version: ${{ matrix.python-version }}
19-
architecture: x64
20-
21-
- name: Install Poetry
22-
uses: snok/install-poetry@v1
23-
with:
24-
virtualenvs-create: true
25-
virtualenvs-in-project: true
14+
- uses: actions/checkout@v4
2615

27-
- name: Cache Poetry virtualenv
28-
uses: actions/cache@v4
29-
id: cached-poetry-dependencies
16+
- name: Install uv and set the python version
17+
uses: astral-sh/setup-uv@v6
3018
with:
31-
path: .venv
32-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
19+
enable-cache: true
20+
python-version: ${{ matrix.python-version }}
3321

34-
- name: Install Dependencies
35-
run: poetry install -E full
36-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
22+
- name: Install the project
23+
run: uv sync --locked --all-extras --dev
3724

3825
- name: Run black
3926
run: make black
@@ -52,33 +39,19 @@ jobs:
5239
platform: [ubuntu-latest, macos-13, windows-latest]
5340
runs-on: ${{ matrix.platform }}
5441
steps:
55-
- uses: actions/checkout@v2
56-
- name: Setup python
57-
uses: actions/setup-python@v1
58-
with:
59-
python-version: ${{ matrix.python-version }}
60-
architecture: x64
61-
62-
- name: Install Poetry
63-
uses: snok/install-poetry@v1
64-
with:
65-
virtualenvs-create: true
66-
virtualenvs-in-project: true
42+
- uses: actions/checkout@v4
6743

68-
- name: Cache Poetry virtualenv
69-
uses: actions/cache@v4
70-
id: cached-poetry-dependencies
44+
- name: Install uv and set the python version
45+
uses: astral-sh/setup-uv@v6
7146
with:
72-
path: .venv
73-
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
74-
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv
47+
enable-cache: true
48+
python-version: ${{ matrix.python-version }}
7549

76-
- name: Install Dependencies
77-
run: poetry install -E full
78-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
50+
- name: Install the project
51+
run: uv sync --locked --all-extras --dev
7952

8053
- name: Run pytest
81-
run: poetry run pytest -vs
54+
run: uv run pytest -vs
8255

8356
pytest_extras:
8457
name: Testing ${{ matrix.extra }} on Python ${{ matrix.python-version }} (${{ matrix.platform}})
@@ -94,32 +67,18 @@ jobs:
9467
runs-on: ${{ matrix.platform }}
9568
steps:
9669
- uses: actions/checkout@v4
97-
- name: Setup python
98-
uses: actions/setup-python@v1
99-
with:
100-
python-version: ${{ matrix.python-version }}
101-
architecture: x64
102-
103-
- name: Install Poetry
104-
uses: snok/install-poetry@v1
105-
with:
106-
virtualenvs-create: true
107-
virtualenvs-in-project: true
10870

109-
- name: Cache Poetry virtualenv
110-
uses: actions/cache@v4
111-
id: cached-poetry-dependencies
71+
- name: Install uv and set the python version
72+
uses: astral-sh/setup-uv@v6
11273
with:
113-
path: .venv
114-
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ matrix.extra }}-${{ hashFiles('**/poetry.lock') }}
115-
if: ${{ matrix.platform != 'windows-latest' }} # windows hangs if using a cached venv
74+
enable-cache: true
75+
python-version: ${{ matrix.python-version }}
11676

117-
- name: Install Dependencies
118-
run: poetry install -E ${{ matrix.extra }}
119-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
77+
- name: Install the project
78+
run: uv sync --locked --extra ${{ matrix.extra }}
12079

12180
- name: Run pytest
122-
run: poetry run pytest -v -m ${{ matrix.extra }}
81+
run: uv run pytest -v -m ${{ matrix.extra }}
12382

12483
release:
12584
name: Releasing to pypi
@@ -128,22 +87,18 @@ jobs:
12887
runs-on: ubuntu-latest
12988
steps:
13089
- uses: actions/checkout@v2
131-
- name: Setup python
132-
uses: actions/setup-python@v1
90+
91+
- name: Install uv and set the python version
92+
uses: astral-sh/setup-uv@v6
13393
with:
94+
enable-cache: true
13495
python-version: "3.9"
135-
136-
- name: Install Poetry
137-
uses: snok/install-poetry@v1
138-
139-
- name: prepare release
140-
run: make fiximageurls
14196

14297
- name: prepare release
14398
run: make fiximageurls
14499

145100
- name: build release
146-
run: poetry build
101+
run: uv build
147102

148103
- name: Publish package to PyPI
149104
uses: pypa/gh-action-pypi-publish@release/v1

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Contributions are highly welcomed and appreciated!
44

55
## Development Environment
66

7-
NetTowel uses [poetry](https://python-poetry.org/docs/) for packaging and
7+
NetTowel uses [uv](https://docs.astral.sh/uv/) for packaging and
88
dependency management.
99

1010
### Tests

Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ FROM python:3.9
33

44
WORKDIR /workspace
55

6-
ENV PATH="/root/.poetry/bin:$PATH" \
7-
PYTHONDONTWRITEBYTECODE=1 \
8-
PYTHONUNBUFFERED=1
9-
10-
11-
RUN apt-get update && apt-get install curl -y \
12-
&& rm -rf /var/lib/apt/lists/* \
13-
&& curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python \
14-
&& poetry config virtualenvs.create false
6+
# Install uv.
7+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
158

169
COPY . .
1710

18-
RUN poetry install --no-dev --extras full --no-interaction --no-ansi
11+
ENV UV_PROJECT_ENVIRONMENT=/usr/local
12+
RUN uv sync --frozen --no-cache --all-extras
1913

2014
CMD ["nettowel", "help"]

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
PROJECT=nettowel
2-
CODE_DIRS=${PROJECT} tests
2+
CODE_DIRS=src/${PROJECT} tests
33
IMG_URL=https://raw.githubusercontent.com/InfrastructureAsCode-ch/nettowel/main/imgs/
44

55
# Run pytest
66
.PHONY: pytest
77
pytest:
8-
poetry run pytest -vs ${ARGS}
8+
uv run pytest -vs ${ARGS}
99

1010
# Check if the python code needs to be reformatted
1111
.PHONY: black
1212
black:
13-
poetry run black --check ${CODE_DIRS}
13+
uv run black --check ${CODE_DIRS}
1414

1515
# Python type check
1616
.PHONY: mypy
1717
mypy:
18-
poetry run mypy ${CODE_DIRS}
18+
uv run mypy ${CODE_DIRS}
1919

2020
# Runn pytest, black and mypy
2121
.PHONY: tests
@@ -24,9 +24,9 @@ tests: pytest black mypy
2424
# use "make bump ARGS=patch" to bump the version. ARGS can be patch, minor or major.
2525
.PHONY: bump
2626
bump:
27-
poetry version ${ARGS}
28-
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" ${PROJECT}/__init__.py
29-
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`poetry version -s`\" # From Makefile|g" tests/test_${PROJECT}.py
27+
uv version --bump ${ARGS}
28+
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" src/${PROJECT}/__init__.py
29+
sed -i -E "s|\"\b[0-9]+.\b[0-9]+.\b[0-9]+\" # From Makefile|\"`uv version --short`\" # From Makefile|g" tests/test_${PROJECT}.py
3030

3131
# Used in the pipeline to change the image urls befor publishing it on pypi.org
3232
.PHONY: fiximageurls
@@ -38,6 +38,6 @@ fiximageurls:
3838
tag:
3939
git checkout main
4040
git pull
41-
git tag -a "v`poetry version -s`" -m "Version v`poetry version -s`"
41+
git tag -a "v`uv version --short`" -m "Version v`uv version --short`"
4242
git push --tags
4343
git checkout -

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pip install nettowel[full]
4949
```
5050
git clone ....
5151
cd nettowel
52-
poetry install
53-
poetry run nettowel --help
52+
uv sync --extra full
53+
uv run nettowel --help
5454
```
5555

5656

0 commit comments

Comments
 (0)