Skip to content

Commit 6e1902b

Browse files
[DOP-28270] migrate from poetry to uv (#302)
* [DOP-28270] migrate from poetry to uv * [DOP-28270] update dev-releaase workflow * [DOP-28270] update dev-releaase workflow * [DOP-28270] update dev-releaase workflow * [DOP-28270] update dev-releaase workflow * [DOP-28270] add verbose output for dev-releaase workflow * [DOP-28270] fix dynamic version for setuptools * [DOP-28270] build with uv * [DOP-28270] build with uv * [DOP-28270] remove dependencie installing from release * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [DOP-28270] fix readthedocs yaml file * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [DOP-28270] add sphinx-tabs * [DOP-28270] change make venv command * [DOP-28270] change make venv command * [DOP-28270] change make venv command * [DOP-28270] fix ci venv * [DOP-28270] fix ci venv * [DOP-28270] up version * [DOP-28270] update dependencies * [DOP-28270] fix venv command * [DOP-28270] add package-data * [DOP-28270] add package-data * [DOP-28270] add package-data --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent af660ab commit 6e1902b

File tree

15 files changed

+2303
-3727
lines changed

15 files changed

+2303
-3727
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,15 @@ jobs:
3535
with:
3636
python-version: ${{ env.DEFAULT_PYTHON }}
3737

38-
- name: Install poetry
39-
uses: snok/install-poetry@v1
40-
with:
41-
virtualenvs-create: true
42-
virtualenvs-in-project: true
43-
virtualenvs-path: .venv
44-
45-
- name: Load cached venv
46-
id: cached-poetry-dependencies
47-
uses: actions/cache@v4
48-
with:
49-
path: .venv
50-
key: venv-${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('**/poetry.lock') }}
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v6
5140

5241
- name: Install dependencies
5342
run: |
5443
make venv
5544
5645
- name: Run mypy
57-
run: poetry run mypy ./data_rentgen --config-file ./pyproject.toml
46+
run: uv run mypy ./data_rentgen --config-file ./pyproject.toml
5847

5948
codeql:
6049
name: CodeQL

.github/workflows/dev-release.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
wait-code-analysis:
2020
name: Dev release package
2121
runs-on: ubuntu-latest
22-
if: github.repository == 'MobileTeleSystems/data-rentgen' # prevent running on forks
22+
if: github.repository == 'MobileTeleSystems/data-rentgen' # prevent running on forks
2323

2424
environment:
2525
name: test-pypi
@@ -32,29 +32,25 @@ jobs:
3232
steps:
3333
- name: Checkout code
3434
uses: actions/checkout@v5
35+
with:
36+
fetch-depth: 0
3537

3638
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
3739
id: python
3840
uses: actions/setup-python@v6
3941
with:
4042
python-version: ${{ env.DEFAULT_PYTHON }}
4143

42-
- name: Install poetry
43-
uses: snok/install-poetry@v1
44-
45-
- name: Generate unique version and update test version
46-
run: |
47-
poetry self add poetry-bumpversion
48-
version=$(poetry version -s)
49-
poetry version "${version}.dev${GITHUB_RUN_ID}"
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v6
5046

5147
- name: Fix logo in Readme
5248
run: |
5349
sed -i "s#image:: docs/#image:: https://raw.githubusercontent.com/MobileTeleSystems/data-rentgen/$GITHUB_SHA/docs/#g" README.rst
5450
sed -i "s#logo_wide_white_text.svg#logo_wide.svg#g" README.rst
5551
5652
- name: Build package
57-
run: poetry build
53+
run: uv build
5854

5955
- name: Publish package
6056
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/release.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
release:
1313
name: Release package
1414
runs-on: ubuntu-latest
15-
if: github.repository == 'MobileTeleSystems/data-rentgen' # prevent running on forks
15+
if: github.repository == 'MobileTeleSystems/data-rentgen' # prevent running on forks
1616

1717
environment:
1818
name: pypi
@@ -36,24 +36,8 @@ jobs:
3636
# this step is needed for successful installation of "bonsai" library in python dependencies
3737
run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev
3838

39-
- name: Install poetry
40-
uses: snok/install-poetry@v1
41-
with:
42-
virtualenvs-create: true
43-
virtualenvs-in-project: true
44-
virtualenvs-path: .venv
45-
46-
- name: Load cached venv
47-
id: cached-poetry-dependencies
48-
uses: actions/cache@v4
49-
with:
50-
path: .venv
51-
key: venv-${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('**/poetry.lock') }}
52-
53-
- name: Install dependencies
54-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
55-
run: |
56-
make venv
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@v6
5741

5842
- name: Generate OpenAPI Schema
5943
run: |
@@ -65,15 +49,15 @@ jobs:
6549
sed -i "s#logo_wide_white_text.svg#logo_wide.svg#g" README.rst
6650
6751
- name: Build package
68-
run: poetry build
52+
run: uv build
6953

7054
- name: Publish package
7155
uses: pypa/gh-action-pypi-publish@release/v1
7256

7357
- name: Generate SBOM
7458
run: |
75-
pip install cyclonedx-bom
76-
cyclonedx-py poetry --extras server,consumer,postgres,gssapi --without dev,test,docs > sbom.cyclonedx.json
59+
uv pip install cyclonedx-bom
60+
cyclonedx-py uv sync --group server,consumer,postgres,gssapi > sbom.cyclonedx.json
7761
7862
- name: Get changelog
7963
run: |

.github/workflows/test.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,10 @@ jobs:
4141
with:
4242
python-version: ${{ env.DEFAULT_PYTHON }}
4343

44-
- name: Install poetry
45-
uses: snok/install-poetry@v1
46-
with:
47-
virtualenvs-create: true
48-
virtualenvs-in-project: true
49-
virtualenvs-path: .venv
50-
51-
- name: Load cached venv
52-
id: cached-poetry-dependencies
53-
uses: actions/cache@v4
54-
with:
55-
path: .venv
56-
key: venv-${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('**/poetry.lock') }}
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v6
5746

5847
- name: Install dependencies
59-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
6048
run: |
6149
make venv
6250

.pre-commit-config.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,10 @@ repos:
8787
additional_dependencies:
8888
- tomli
8989

90-
- repo: https://github.com/sbrunner/hooks
91-
rev: 1.6.1
90+
- repo: https://github.com/astral-sh/uv-pre-commit
91+
rev: 0.7.19
9292
hooks:
93-
- id: poetry-check
94-
additional_dependencies:
95-
- poetry
96-
- id: poetry-lock
97-
additional_dependencies:
98-
- poetry
93+
- id: uv-lock
9994

10095
- repo: local
10196
hooks:

.readthedocs.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ build:
1212
post_checkout:
1313
- git fetch --unshallow || true
1414
post_create_environment:
15-
- python -m pip install poetry
16-
- python -m pip install --no-deps sphinx-plantuml # remove after https://github.com/zqmillet/sphinx-plantuml/pull/4
17-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry config virtualenvs.create false
18-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry debug info
15+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH python -m pip install uv
16+
1917
post_install:
20-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --no-root --extras server --extras consumer --extras postgres --extras seed --with docs --without dev,test
21-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry show -v
18+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --no-install-project --extra server --extra consumer --extra postgres --extra seed --group docs
19+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv pip install --no-deps sphinx-plantuml # remove after https://github.com/zqmillet/sphinx-plantuml/pull/4
2220
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m pip list -v
2321
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make docs-openapi
2422

CONTRIBUTING.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If you already have venv, but need to install dependencies required for developm
4949
5050
make venv-install
5151
52-
We are using `poetry <https://python-poetry.org/docs/managing-dependencies/>`_ for managing dependencies and building the package.
52+
We are using `uv https://docs.astral.sh/uv/`_ for managing dependencies and building the package.
5353
It allows to keep development environment the same for all developers due to using lock file with fixed dependency versions.
5454

5555
There are *extra* dependencies (included into package as optional):
@@ -334,8 +334,8 @@ Before making a release from the ``develop`` branch, follow these steps:
334334

335335
.. code:: bash
336336
337-
VERSION=$(poetry version -s)
338-
towncrier build "--version=${VERSION}" --yes
337+
VERSION=$(cat data_rentgen/VERSION)
338+
towncrier build --version=${VERSION} --yes
339339
340340
3. Change file with changelog to release version number
341341

@@ -392,7 +392,7 @@ Before making a release from the ``develop`` branch, follow these steps:
392392
git checkout develop
393393
394394
NEXT_VERSION=$(echo "$VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
395-
poetry version "$NEXT_VERSION"
395+
echo $NEXT_VERSION > data_rentgen/VERSION
396396
397397
git add .
398398
git commit -m "Bump version"

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ VERSION = develop
66
VIRTUAL_ENV ?= .venv
77
PYTHON = ${VIRTUAL_ENV}/bin/python
88
PIP = ${VIRTUAL_ENV}/bin/pip
9-
POETRY = ${VIRTUAL_ENV}/bin/poetry
9+
UV = ${VIRTUAL_ENV}/bin/uv
1010
PYTEST = ${VIRTUAL_ENV}/bin/pytest
1111
COVERAGE = ${VIRTUAL_ENV}/bin/coverage
1212

@@ -30,17 +30,16 @@ help: ##@Help Show this help
3030

3131

3232

33-
venv: venv-init venv-install##@Env Init venv and install poetry dependencies
33+
venv: venv-cleanup venv-install##@Env Init venv and install uv dependencies
3434

35-
venv-init: ##@Env Init venv
36-
python -m venv ${VIRTUAL_ENV}
35+
venv-cleanup: ##@Env Cleanup venv
36+
@rm -rf .venv || true
37+
python3.12 -m venv .venv
3738
${PIP} install -U setuptools wheel pip
38-
${PIP} install poetry poetry-bumpversion
39+
${PIP} install uv
3940

4041
venv-install: ##@Env Install requirements to venv
41-
${POETRY} config virtualenvs.create false
42-
${POETRY} install --no-root --extras server --extras consumer --extras postgres --extras seed --with dev,test,docs $(ARGS)
43-
${PIP} install --no-deps sphinx-plantuml
42+
${UV} sync --inexact --frozen --all-extras --all-groups --no-extra gssapi $(ARGS)
4443

4544

4645
db: db-start db-upgrade db-partitions ##@DB Prepare database (in docker)
@@ -67,7 +66,7 @@ db-cleanup-partitions-ci: ##@DB Clean partitions in CI
6766
${PYTHON} -m data_rentgen.db.scripts.cleanup_partitions $(ARGS)
6867

6968
db-views: ##@DB Create views
70-
${POETRY} run coverage run python -m data_rentgen.db.scripts.refresh_analytic_views $(ARGS)
69+
${UV} run coverage run python -m data_rentgen.db.scripts.refresh_analytic_views $(ARGS)
7170

7271
db-seed: ##@DB Seed database with random data
7372
${PYTHON} -m data_rentgen.db.scripts.seed $(ARGS)

data_rentgen/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.4.0

data_rentgen/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# SPDX-FileCopyrightText: 2024-2025 MTS PJSC
22
# SPDX-License-Identifier: Apache-2.0
33

4-
# _raw_version could contain pre-release version, like 0.0.1dev123
5-
# value is updated automatically by `poetry version ...` and poetry-bumpversion plugin
6-
_raw_version = "0.4.0"
4+
from pathlib import Path
75

6+
VERSION_FILE = Path(__file__).parent / "VERSION"
87
# version always contain only release number like 0.0.1
9-
__version__ = ".".join(_raw_version.split(".")[:3])
10-
8+
__version__ = VERSION_FILE.read_text().strip()
119
# version tuple always contains only integer parts, like (0, 0, 1)
1210
__version_tuple__ = tuple(map(int, __version__.split("."))) # noqa: RUF048

0 commit comments

Comments
 (0)