Skip to content

Commit 790bdbe

Browse files
authored
Merge pull request #595 from plugwise/uv
Follow beta/core with uv
2 parents 672335d + a55e70b commit 790bdbe

File tree

6 files changed

+42
-8
lines changed

6 files changed

+42
-8
lines changed

.github/workflows/verify.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ jobs:
4848
pip install virtualenv --upgrade
4949
python -m venv venv
5050
. venv/bin/activate
51-
pip install -U pip setuptools wheel
52-
pip install -r requirements_test.txt -r requirements_commit.txt
51+
pip install uv
52+
uv pip install -U pip setuptools wheel
53+
uv pip install -r requirements_test.txt -r requirements_commit.txt
54+
# TODO: Remove after update of aiohttp beyond 3.10.0
55+
uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" )
5356
- name: Restore pre-commit environment from cache
5457
id: cache-precommit
5558
uses: actions/cache@v4
@@ -97,7 +100,7 @@ jobs:
97100
- name: Ruff (with fix)
98101
run: |
99102
. venv/bin/activate
100-
ruff plugwise/*py tests/*py
103+
ruff check --fix plugwise/*py tests/*py
101104
- name: If needed, commit ruff changes to the pull request
102105
if: failure()
103106
run: |
@@ -194,11 +197,14 @@ jobs:
194197
run: |
195198
python -m venv venv
196199
. venv/bin/activate
197-
pip install -U pip setuptools wheel
200+
pip install uv
201+
uv pip install -U pip setuptools wheel
198202
#pip install -r requirements_test.txt
199203
# 20220124 Mimic setup_test.sh
200-
pip install --upgrade -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt
201-
pip install --upgrade pytest-asyncio
204+
uv pip install --upgrade -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt
205+
uv pip install --upgrade pytest-asyncio
206+
# TODO: Remove after update of aiohttp beyond 3.10.0
207+
uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" )
202208
203209
pytest:
204210
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## ongoing
4+
5+
- Note2self; remove aiohttp 3.10 test fixing in scripts/* and verify workflow
6+
37
## v0.38.3
48

59
- Implement fix for Core Issue [#119686](https://github.com/home-assistant/core/issues/119686)

patch/aiohttp310.patch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- venv/lib/python3.12/site-packages/aiohttp/web_urldispatcher.py 2024-08-01 13:01:32
2+
+++ /tmp/web_urldispatcher.py 2024-08-01 22:37:19
3+
@@ -1132,15 +1132,7 @@
4+
def _get_resource_index_key(self, resource: AbstractResource) -> str:
5+
"""Return a key to index the resource in the resource index."""
6+
# strip at the first { to allow for variables
7+
- #return resource.canonical.partition("{")[0].rstrip("/") or "/"
8+
- if "{" in (index_key := resource.canonical):
9+
- # strip at the first { to allow for variables, and than
10+
- # rpartition at / to allow for variable parts in the path
11+
- # For example if the canonical path is `/core/locations{tail:.*}`
12+
- # the index key will be `/core` since index is based on the
13+
- # url parts split by `/`
14+
- index_key = index_key.partition("{")[0].rpartition("/")[0]
15+
- return index_key.rstrip("/") or "/"
16+
+ return resource.canonical.partition("{")[0].rstrip("/") or "/"
17+
18+
def index_resource(self, resource: AbstractResource) -> None:
19+
"""Add a resource to the resource index."""

requirements_test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ radon==6.0.1
66
types-python-dateutil
77
# Added for prettier
88
nodeenv==1.9.1
9+
uv

scripts/tests_and_coverage.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ fi
2424
# Install/update dependencies
2525
pre-commit install
2626
pre-commit install-hooks
27-
pip install -r requirements_test.txt -r requirements_commit.txt
27+
pip install uv
28+
uv pip install -r requirements_test.txt -r requirements_commit.txt
29+
# TODO: Remove after update of aiohttp beyond 3.10.0
30+
# shellcheck disable=SC2015
31+
uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" )
2832

2933
set +u
3034

tests/INIT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Once the project is ready for upload to test (i.e. version number ending in `a0`
2727

2828
Prepare:
2929

30-
- [ ] `python3 -m venv venv ; source venv/bin/activate ; pip install --upgrade pip; pip install -r requirements_test.txt ; pip install --upgrade setuptools wheel twine`
30+
- [ ] `python3 -m venv venv ; source venv/bin/activate ; pip install --upgrade pip; pip install uv; uv pip install -r requirements_test.txt ; uv pip install --upgrade setuptools wheel twine`
3131

3232
Package: (**ensure you are in your venv**)
3333

0 commit comments

Comments
 (0)