Migrate from poetry to uv

dependabot/pip/json-stream-gte-2.5.1-and-lt-3
alufers 4 months ago
parent d3f7bf9432
commit abea8a1139

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

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

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

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

2396
poetry.lock generated

File diff suppressed because it is too large Load Diff

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

2443
uv.lock

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