Skip to content

Commit d7af466

Browse files
authored
Replace Poetry with uv for dependency management (#2079)
1 parent 1374cfd commit d7af466

8 files changed

Lines changed: 1984 additions & 2075 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ jobs:
1919

2020
steps:
2121
- uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1
22-
- uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065" # v5.6.0
22+
- uses: "astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e" # v6
2323
with:
24+
enable-cache: true
2425
python-version: "${{ matrix.python-version }}"
2526
- name: "Install dependencies"
26-
run: |
27-
python -m pip install --upgrade pip "poetry==2.0.1"
28-
poetry install --extras docs
27+
run: uv sync --extra docs
2928
- name: "Run pre-commit hooks"
30-
run: |
31-
poetry run pre-commit run --all-files --verbose
29+
run: uv run pre-commit run --all-files --verbose
3230

3331
tests:
3432
name: "Python ${{ matrix.python-version}} on ${{ matrix.os }}"
@@ -43,16 +41,14 @@ jobs:
4341

4442
steps:
4543
- uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1
46-
- uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065" # v5.6.0
44+
- uses: "astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e" # v6
4745
with:
46+
enable-cache: true
4847
python-version: "${{ matrix.python-version }}"
4948
- name: "Install dependencies"
50-
run: |
51-
python -m pip install --upgrade pip "poetry==2.0.1"
52-
poetry install --all-extras
49+
run: uv sync --all-extras
5350
- name: "Run tests"
54-
run: |
55-
poetry run pytest --cov miio --cov-report xml
51+
run: uv run pytest --cov miio --cov-report xml
5652
- name: "Upload coverage to Codecov"
5753
uses: "codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac" # v5.5.5
5854
with:

RELEASING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export NEW_RELEASE=0.5.1
88
2. Update the version number
99

1010
```
11-
poetry version $NEW_RELEASE
11+
uv version $NEW_RELEASE
1212
```
1313

1414
2. Generate changelog since the last release
@@ -43,14 +43,14 @@ git push --tags
4343

4444
If not done already, create an API key for pypi (https://pypi.org/manage/account/token/) and configure it:
4545
```
46-
poetry config pypi-token.pypi <token>
46+
uv publish --token <token>
4747
```
4848

4949
To build & release:
5050

5151
```bash
52-
poetry build
53-
poetry publish
52+
uv build
53+
uv publish
5454
```
5555

5656
8. Click the "Draft a new release" button on github, select the new tag and copy & paste the changelog into the description.

docs/contributing.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ Development environment
1919
-----------------------
2020

2121
This section will shortly go through how to get you started with a working development environment.
22-
We use `poetry <https://python-poetry.org/>`__ for managing the dependencies and packaging, so simply execute::
22+
We use `uv <https://docs.astral.sh/uv>`__ for managing the dependencies and packaging, so simply execute::
2323

24-
poetry install
24+
uv sync
2525

26-
If you were not already inside a virtual environment during the install,
27-
poetry will create one for you.
28-
You can execute commands inside this environment by using ``poetry run <command>``,
26+
uv will create a virtual environment for you automatically.
27+
You can execute commands inside this environment by using ``uv run <command>``,
2928
or alternatively,
30-
enter the virtual environment shell by executing ``poetry shell`` to avoid repeating ``poetry run``.
29+
activate the virtual environment with ``source .venv/bin/activate`` to avoid repeating ``uv run``.
3130

3231
To verify the installation, you can launch tox_ to run all the checks::
3332

docs/discovery.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ You can install the most recent release using pip:
1414
pip install python-miio
1515
1616
17-
Alternatively, you can clone this repository and use `poetry <https://python-poetry.org>`_ to install the current master:
17+
Alternatively, you can clone this repository and use `uv <https://docs.astral.sh/uv>`_ to install the current master:
1818

1919
.. code-block:: console
2020
2121
git clone https://github.com/rytilahti/python-miio.git
2222
cd python-miio/
23-
poetry install
23+
uv sync
2424
2525
This will install python-miio into a separate virtual environment outside of your regular python installation.
2626
You can then execute installed programs (like ``miiocli``):
2727

2828
.. code-block:: console
2929
30-
poetry run miiocli --help
30+
uv run miiocli --help
3131
3232
.. tip::
3333

3434
If you want to execute more commands in a row, you can activate the
35-
created virtual environment to avoid typing ``poetry run`` for each
35+
created virtual environment to avoid typing ``uv run`` for each
3636
invocation:
3737

3838
.. code-block:: console
3939
40-
poetry shell
40+
source .venv/bin/activate
4141
miiocli --help
4242
miiocli discover
4343

miio/push_server/test_serverprotocol.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import asyncio
2+
13
import pytest
24

35
from miio import Message
@@ -16,17 +18,20 @@
1618

1719

1820
@pytest.fixture
19-
def protocol(mocker, event_loop) -> ServerProtocol:
21+
def protocol(mocker) -> ServerProtocol:
22+
loop = asyncio.new_event_loop()
2023
server = mocker.Mock()
2124

2225
# Mock server id
2326
type(server).device_id = mocker.PropertyMock(return_value=DEVICE_ID)
2427
socket = mocker.Mock()
2528

26-
proto = ServerProtocol(event_loop, socket, server)
29+
proto = ServerProtocol(loop, socket, server)
2730
proto.transport = mocker.Mock()
2831

29-
return proto
32+
yield proto
33+
34+
loop.close()
3035

3136

3237
def test_send_ping_ack(protocol: ServerProtocol, mocker):

0 commit comments

Comments
 (0)