Skip to content

Commit 006bb5d

Browse files
committed
Migrate to UV
1 parent 53344af commit 006bb5d

5 files changed

Lines changed: 48 additions & 59 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
2525
libffi-dev \
2626
liblzma-dev
2727

28-
# Python and poetry installation
28+
# Python and uv installation
2929
USER $USER
3030
ARG HOME="/home/$USER"
3131
ARG PYTHON_VERSION=3.9
@@ -41,5 +41,4 @@ RUN echo "done 0" \
4141
&& echo "done 2" \
4242
&& pyenv global ${PYTHON_VERSION} \
4343
&& echo "done 3" \
44-
&& curl -sSL https://install.python-poetry.org | python3 - \
45-
&& poetry config virtualenvs.in-project true
44+
&& curl -LsSf https://astral.sh/uv/install.sh | sh

.github/workflows/release.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ jobs:
2727
with:
2828
python-version: "3.9"
2929

30-
- name: Install Poetry
31-
uses: snok/install-poetry@v1
30+
- name: Install UV
31+
uses: astral-sh/setup-uv@v3
3232
with:
33-
virtualenvs-create: true
34-
virtualenvs-in-project: true
33+
enable-cache: true
3534

3635
- name: Install dependencies
37-
run: poetry install --only dev
36+
run: uv sync
3837

3938
- name: Version Check and population of PROJECT_VERSION var
4039
run: |
41-
PROJECT_VERSION=$(poetry version --short)
40+
PROJECT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
4241
TAG=$(git describe HEAD --tags --abbrev=0)
4342
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
4443
echo "Project version: $PROJECT_VERSION"
@@ -62,9 +61,9 @@ jobs:
6261
- name: Build sdist, wheel, and pex
6362
run: >
6463
mkdir -p dist
65-
&& poetry export -E codegen --without dev --format requirements.txt --output dist/requirements.txt --without-hashes
66-
&& poetry build
67-
&& poetry run pex . --scie eager -o dist/asyncapi-python-codegen.pex -e asyncapi_python_codegen:app -r dist/requirements.txt
64+
&& uv export --extra codegen --no-dev --format requirements-txt --output-file dist/requirements.txt --no-hashes
65+
&& uv build
66+
&& uv run pex . --scie eager -o dist/asyncapi-python-codegen.pex -e asyncapi_python_codegen:app -r dist/requirements.txt
6867
6968
- name: Upload wheel to Release
7069
uses: actions/upload-release-asset@v1

.github/workflows/test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ jobs:
2929
with:
3030
python-version: ${{ matrix.python_version }}
3131

32-
- name: Install Poetry
33-
uses: snok/install-poetry@v1
32+
- name: Install UV
33+
uses: astral-sh/setup-uv@v3
3434
with:
35-
virtualenvs-create: true
36-
virtualenvs-in-project: true
35+
enable-cache: true
3736

3837
- name: Install dependencies
39-
run: poetry install --all-extras
38+
run: uv sync --all-extras
4039

4140
- name: Run tests
4241
env:
4342
AMQP_URI: amqp://localhost:${{ job.services.rabbitmq.ports[5672] }}
44-
run: poetry run pytest
43+
run: uv run pytest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Project-specific ###
22
.vscode
3-
poetry.lock
3+
uv.lock
44

55
# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,vim,emacs,visualstudiocode,jetbrains+all,python
66
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,vim,emacs,visualstudiocode,jetbrains+all,python

pyproject.toml

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,51 @@
1-
[tool.poetry]
1+
[project]
22
name = "asyncapi-python"
33
version = "0.2.5"
4-
license = "Apache-2.0"
4+
license = {text = "Apache-2.0"}
55
description = "Easily generate type-safe and async Python applications from AsyncAPI 3 specifications."
6-
authors = ["Yaroslav Petrov <yaroslav.v.petrov@gmail.com>"]
6+
authors = [{name = "Yaroslav Petrov", email = "yaroslav.v.petrov@gmail.com"}]
77
readme = "README.md"
8-
packages = [
9-
{ include = "asyncapi_python_pants", from = "src" },
10-
{ include = "asyncapi_python_codegen", from = "src" },
11-
{ include = "asyncapi_python", from = "src" },
8+
requires-python = ">=3.9,<3.14"
9+
dependencies = [
10+
"pydantic>=2",
11+
"pytz",
1212
]
1313

14-
[tool.poetry.scripts]
15-
asyncapi-python-codegen = "asyncapi_python_codegen:app"
16-
17-
[tool.poetry.extras]
14+
[project.optional-dependencies]
1815
codegen = [
19-
"jinja2",
20-
"typer",
21-
"asyncapi_python_codegen",
16+
"jinja2>=3.1.4",
17+
"typer[all]>=0.12.5",
2218
"pyyaml",
23-
"datamodel-code-generator",
19+
"datamodel-code-generator[http]>=0.26.4",
2420
"black",
2521
]
2622
amqp = ["aio-pika"]
2723

28-
[tool.poetry.dependencies]
29-
python = ">=3.9,<3.14"
30-
pydantic = ">=2"
31-
pytz = "*"
32-
jinja2 = { version = "^3.1.4", optional = true }
33-
typer = { extras = ["all"], version = "^0.12.5", optional = true }
34-
datamodel-code-generator = { extras = [
35-
"http",
36-
], version = "^0.26.4", optional = true }
37-
aio-pika = { version = "*", optional = true }
38-
pyyaml = { version = "*", optional = true }
39-
black = { version = "*", optional = true }
24+
[project.scripts]
25+
asyncapi-python-codegen = "asyncapi_python_codegen:app"
4026

41-
[tool.poetry.group.dev.dependencies]
42-
black = "*"
43-
mypy = "*"
44-
isort = "*"
45-
types-pyyaml = "*"
46-
pytest = "*"
47-
types-pytz = "*"
48-
pytest-asyncio = "*"
49-
pex = "*"
27+
[tool.uv]
28+
dev-dependencies = [
29+
"black",
30+
"mypy",
31+
"isort",
32+
"types-pyyaml",
33+
"pytest",
34+
"types-pytz",
35+
"pytest-asyncio",
36+
"pex",
37+
]
5038

5139
[build-system]
52-
requires = ["poetry-core"]
53-
build-backend = "poetry.core.masonry.api"
40+
requires = ["hatchling"]
41+
build-backend = "hatchling.build"
5442

55-
[tool.poetry.requires-plugins]
56-
poetry-plugin-export = ">=1.8"
43+
[tool.hatch.build.targets.wheel]
44+
packages = [
45+
"src/asyncapi_python_pants",
46+
"src/asyncapi_python_codegen",
47+
"src/asyncapi_python",
48+
]
5749

5850
[tool.pytest.ini_options]
5951
asyncio_mode = "auto"

0 commit comments

Comments
 (0)