Migrate from poetry to uv

master
alufers 5 days ago
parent d3f7bf9432
commit abea8a1139

@ -22,18 +22,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: "3.12"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.5"
version: "latest"
- name: Install dependencies
run: |
poetry install
uv sync
- name: Run Python tests
run: |
poetry run pytest --cov
uv run pytest --cov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

@ -22,39 +22,36 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: "3.12"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.5"
version: "latest"
- name: Install dependencies
run: |
poetry install
uv sync
- name: Run Python lint checks
run: |
poetry run pre-commit run --all-files
uv run pre-commit run --all-files
- name: Run Python tests
run: |
poetry run pytest --cov
uv run pytest --cov
- name: Git configuration
run: |
git config --global user.email "bot@example.com"
git config --global user.name "GitHub Actions"
- name: Bump release version
run: |
poetry version ${{ github.event.inputs.release-type }}
echo "NEW_VERSION=$(poetry version --short)" >> $GITHUB_ENV
uvx hatch version ${{ github.event.inputs.release-type }}
echo "NEW_VERSION=$(uvx hatch version)" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Build package
run: |
poetry lock
poetry build
- name: Commit pyproject.toml and poetry.lock
uv lock
uv build
- name: Commit pyproject.toml and uv.lock
run: |
git add pyproject.toml poetry.lock
git add pyproject.toml uv.lock
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
git push origin master
@ -69,9 +66,9 @@ jobs:
# Push repository changes
- name: Publish package
run: |
poetry publish --build
uv publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Push docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:

@ -1,17 +1,13 @@
FROM python:3.12-slim-bookworm AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_HTTP_TIMEOUT=100 \
UV_NO_CACHE=1
UV_NO_CACHE=1 \
UV_PROJECT_ENVIRONMENT=/venv
WORKDIR /app
RUN uv pip install --system poetry poetry-plugin-export
COPY pyproject.toml poetry.lock ./
RUN uv venv /venv && \
poetry config warnings.export false && \
poetry export -f requirements.txt -o requirements.txt && \
VIRTUAL_ENV=/venv uv pip install -r requirements.txt
COPY pyproject.toml uv.lock ./
RUN uv sync --no-dev --frozen --no-install-project
COPY . .
RUN poetry build && \
VIRTUAL_ENV=/venv uv pip install dist/*.whl
RUN uv sync --no-dev --frozen
FROM python:3.12-slim-bookworm AS final
ENV PYTHONFAULTHANDLER=1 \

@ -129,14 +129,14 @@ See the generated html file [here](https://raw.githack.com/alufers/mitmproxy2swa
This project uses:
- [poetry](https://python-poetry.org/) for dependency management
- [uv](https://docs.astral.sh/uv/) for dependency management
- [pre-commit](https://pre-commit.com/) for code formatting and linting
- [pytest](https://docs.pytest.org/en/stable/) for unit testing
To install the dependencies:
```bash
poetry install
uv sync
```
Run linters:
@ -154,13 +154,13 @@ pre-commit install
Run tests:
```bash
poetry run pytest
uv run pytest
```
Run tests with coverage:
```bash
poetry run pytest --cov=mitmproxy2swagger
uv run pytest --cov=mitmproxy2swagger
```
## License

2396
poetry.lock generated

File diff suppressed because it is too large Load Diff

@ -1,46 +1,44 @@
[tool.poetry]
[project]
name = "mitmproxy2swagger"
version = "0.14.0"
description = ""
authors = ["alufers <alufers@wp.pl>"]
authors = [{name = "alufers", email = "alufers@wp.pl"}]
readme = "README.md"
license = "MIT"
[tool.poetry.dependencies]
python = "^3.10"
mitmproxy = "^11.0.2"
"ruamel.yaml" = ">=0.17.32,<0.19.0"
json-stream = "^2.3.2"
msgpack = "^1.0.7"
[tool.poetry.group.dev.dependencies]
black = "^24.10.0"
isort = "^5.12.0"
mypy = "^1.13.0"
flake8 = "^7.1.1"
docformatter = {extras = ["tomli"], version = "^1.7.1"}
pre-commit = "^4.0.1"
pytest = "^8.3.3"
pytest-asyncio = ">=0.20.3,<0.25.0"
vermin = "^1.5.1"
openapi-spec-validator = ">=0.5.6,<0.8.0"
pytest-cov = "^6.0.0"
license = {text = "MIT"}
requires-python = ">=3.10"
dependencies = [
"mitmproxy>=11.0.2,<12",
"ruamel.yaml>=0.17.32,<0.19.0",
"json-stream>=2.3.2,<3",
"msgpack>=1.0.7,<2",
]
[project.scripts]
mitmproxy2swagger = "mitmproxy2swagger.mitmproxy2swagger:main"
[dependency-groups]
dev = [
"black>=24.10.0,<25",
"isort>=5.12.0,<6",
"mypy>=1.13.0,<2",
"flake8>=7.1.1,<8",
"docformatter[tomli]>=1.7.1,<2",
"pre-commit>=4.0.1,<5",
"pytest>=8.3.3,<9",
"pytest-asyncio>=0.20.3,<0.25.0",
"vermin>=1.5.1,<2",
"openapi-spec-validator>=0.5.6,<0.8.0",
"pytest-cov>=6.0.0,<7",
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
mitmproxy2swagger = 'mitmproxy2swagger.mitmproxy2swagger:main'
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.black]
line-length = 88
target-version = ['py310']
[tool.isort]
profile = "black"

2443
uv.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save