Skip to content

Commit f65c55b

Browse files
committed
Update scripts wrt uv and venv
1 parent 72b5c78 commit f65c55b

File tree

6 files changed

+188
-206
lines changed

6 files changed

+188
-206
lines changed

scripts/complexity.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ set -eu
33

44
my_path=$(git rev-parse --show-toplevel)
55

6-
# shellcheck disable=SC1091
7-
source "${my_path}/scripts/python-venv.sh"
8-
9-
# shellcheck disable=SC2154
10-
if [ -f "${my_venv}/bin/activate" ]; then
11-
# shellcheck disable=SC1091
12-
. "${my_venv}/bin/activate"
13-
echo "-----------------------------"
14-
echo "Running cyclomatic complexity"
15-
echo "-----------------------------"
16-
PYTHONPATH=$(pwd) radon cc plugwise/ tests/ -s -nc --no-assert
6+
if [ -n "${VIRTUAL_ENV-}" ] && [ -f "${VIRTUAL_ENV}/bin/activate" ]; then
7+
. "${VIRTUAL_ENV}/bin/activate"
178
else
18-
echo "Virtualenv available, bailing out"
19-
exit 2
9+
# other common virtualenvs
10+
my_path=$(git rev-parse --show-toplevel)
11+
12+
for venv in venv .venv .; do
13+
if [ -f "${my_path}/${venv}/bin/activate" ]; then
14+
. "${my_path}/${venv}/bin/activate"
15+
break
16+
fi
17+
done
2018
fi
19+
20+
echo "-----------------------------"
21+
echo "Running cyclomatic complexity"
22+
echo "-----------------------------"
23+
PYTHONPATH=$(pwd) radon cc plugwise/ tests/ -s -nc --no-assert

scripts/manual_fixtures.py

Lines changed: 63 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def json_writer(manual_name: str, output: dict) -> None:
3636
adam_multiple_devices_per_zone = base.copy()
3737

3838
# Change schedule to not present for "446ac08dd04d4eff8ac57489757b7314"
39-
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"].pop("available_schedules")
40-
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"].pop("select_schedule")
39+
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"].pop(
40+
"available_schedules"
41+
)
42+
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"].pop(
43+
"select_schedule"
44+
)
4145

4246
json_writer("m_adam_multiple_devices_per_zone", adam_multiple_devices_per_zone)
4347

@@ -73,24 +77,12 @@ def json_writer(manual_name: str, output: dict) -> None:
7377
m_adam_cooling.pop("10016900610d4c7481df78c89606ef22")
7478

7579
# Correct setpoint for device "ad4838d7d35c4d6ea796ee12ae5aedf8" and zone "f2bf9048bef64cc5b6d5110154e33c81"
76-
m_adam_cooling["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"][
77-
"setpoint"
78-
] = 23.5
79-
m_adam_cooling["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"][
80-
"temperature"
81-
] = 25.8
82-
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["thermostat"][
83-
"setpoint"
84-
] = 23.5
85-
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["sensors"][
86-
"temperature"
87-
] = 25.8
88-
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"][
89-
"select_schedule"
90-
] = "off"
91-
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"][
92-
"control_state"
93-
] = "cooling"
80+
m_adam_cooling["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"]["setpoint"] = 23.5
81+
m_adam_cooling["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"]["temperature"] = 25.8
82+
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["thermostat"]["setpoint"] = 23.5
83+
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["sensors"]["temperature"] = 25.8
84+
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["select_schedule"] = "off"
85+
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = "cooling"
9486
m_adam_cooling["f2bf9048bef64cc5b6d5110154e33c81"]["climate_mode"] = "cool"
9587

9688
# Add new key available
@@ -105,39 +97,23 @@ def json_writer(manual_name: str, output: dict) -> None:
10597
m_adam_cooling.pop("854f8a9b0e7e425db97f1f110e1ce4b3")
10698

10799
# Go for 1772
108-
m_adam_cooling["1772a4ea304041adb83f357b751341ff"]["sensors"][
109-
"temperature"
110-
] = 21.6
100+
m_adam_cooling["1772a4ea304041adb83f357b751341ff"]["sensors"]["temperature"] = 21.6
111101

112102
# Go for e2f4
113-
m_adam_cooling["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"][
114-
"setpoint"
115-
] = 23.5
116-
m_adam_cooling["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"][
117-
"temperature"
118-
] = 23.9
119-
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["thermostat"][
120-
"setpoint"
121-
] = 25.0
122-
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["sensors"][
123-
"temperature"
124-
] = 23.9
125-
m_adam_cooling["f871b8c4d63549319221e294e4f88074"][
126-
"control_state"
127-
] = "cooling"
103+
m_adam_cooling["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"]["setpoint"] = 23.5
104+
m_adam_cooling["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"]["temperature"] = 23.9
105+
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["thermostat"]["setpoint"] = 25.0
106+
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["sensors"]["temperature"] = 23.9
107+
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["control_state"] = "cooling"
128108
m_adam_cooling["f871b8c4d63549319221e294e4f88074"]["climate_mode"] = "auto"
129109

130110

131111
# Go for da22
132-
m_adam_cooling["da224107914542988a88561b4452b0f6"][
133-
"select_regulation_mode"
134-
] = "cooling"
135-
m_adam_cooling["da224107914542988a88561b4452b0f6"][
136-
"regulation_modes"
137-
].append("cooling")
138-
m_adam_cooling["da224107914542988a88561b4452b0f6"]["sensors"][
139-
"outdoor_temperature"
140-
] = 29.65
112+
m_adam_cooling["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "cooling"
113+
m_adam_cooling["da224107914542988a88561b4452b0f6"]["regulation_modes"].append("cooling")
114+
m_adam_cooling["da224107914542988a88561b4452b0f6"]["sensors"]["outdoor_temperature"] = (
115+
29.65
116+
)
141117

142118
# Go for 056e
143119
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
@@ -146,12 +122,12 @@ def json_writer(manual_name: str, output: dict) -> None:
146122
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
147123
"heating_state"
148124
] = False
149-
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
150-
"flame_state"
151-
] = False
152-
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["sensors"][
153-
"water_temperature"
154-
] = 19.0
125+
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["flame_state"] = (
126+
False
127+
)
128+
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["sensors"]["water_temperature"] = (
129+
19.0
130+
)
155131
m_adam_cooling["056ee145a816487eaa69243c3280f8bf"]["sensors"][
156132
"intended_boiler_temperature"
157133
] = 17.5
@@ -163,56 +139,30 @@ def json_writer(manual_name: str, output: dict) -> None:
163139
m_adam_heating = m_adam_cooling.copy()
164140

165141
# Correct setpoint for "ad4838d7d35c4d6ea796ee12ae5aedf8"
166-
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["thermostat"][
167-
"setpoint"
168-
] = 20.0
169-
m_adam_heating["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"][
170-
"setpoint"
171-
] = 20.0
172-
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["sensors"][
173-
"temperature"
174-
] = 19.1
175-
m_adam_heating["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"][
176-
"temperature"
177-
] = 19.1
142+
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["thermostat"]["setpoint"] = 20.0
143+
m_adam_heating["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"]["setpoint"] = 20.0
144+
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["sensors"]["temperature"] = 19.1
145+
m_adam_heating["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"]["temperature"] = 19.1
178146

179-
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"][
180-
"control_state"
181-
] = "preheating"
147+
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = "preheating"
182148
m_adam_heating["f2bf9048bef64cc5b6d5110154e33c81"]["climate_mode"] = "heat"
183149

184150
# Go for 1772
185-
m_adam_heating["1772a4ea304041adb83f357b751341ff"]["sensors"][
186-
"temperature"
187-
] = 18.6
151+
m_adam_heating["1772a4ea304041adb83f357b751341ff"]["sensors"]["temperature"] = 18.6
188152
# Related zone temperature is set below
189153

190154
# Go for e2f4
191-
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["thermostat"][
192-
"setpoint"
193-
] = 15.0
194-
m_adam_heating["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"][
195-
"setpoint"
196-
] = 15.0
197-
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["sensors"][
198-
"temperature"
199-
] = 17.9
200-
m_adam_heating["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"][
201-
"temperature"
202-
] = 17.9
155+
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["thermostat"]["setpoint"] = 15.0
156+
m_adam_heating["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"]["setpoint"] = 15.0
157+
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["sensors"]["temperature"] = 17.9
158+
m_adam_heating["e2f4322d57924fa090fbbc48b3a140dc"]["sensors"]["temperature"] = 17.9
203159

204160
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["climate_mode"] = "auto"
205-
m_adam_heating["f871b8c4d63549319221e294e4f88074"][
206-
"control_state"
207-
] = "idle"
161+
m_adam_heating["f871b8c4d63549319221e294e4f88074"]["control_state"] = "idle"
208162

209163
# Go for da22
210-
m_adam_heating["da224107914542988a88561b4452b0f6"][
211-
"select_regulation_mode"
212-
] = "heating"
213-
m_adam_heating["da224107914542988a88561b4452b0f6"][
214-
"regulation_modes"
215-
].remove("cooling")
164+
m_adam_heating["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = "heating"
165+
m_adam_heating["da224107914542988a88561b4452b0f6"]["regulation_modes"].remove("cooling")
216166
m_adam_heating["da224107914542988a88561b4452b0f6"]["sensors"][
217167
"outdoor_temperature"
218168
] = -1.25
@@ -224,12 +174,12 @@ def json_writer(manual_name: str, output: dict) -> None:
224174
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
225175
"heating_state"
226176
] = True
227-
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
228-
"flame_state"
229-
] = False
230-
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["sensors"][
231-
"water_temperature"
232-
] = 37.0
177+
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"]["flame_state"] = (
178+
False
179+
)
180+
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["sensors"]["water_temperature"] = (
181+
37.0
182+
)
233183
m_adam_heating["056ee145a816487eaa69243c3280f8bf"]["sensors"][
234184
"intended_boiler_temperature"
235185
] = 38.1
@@ -252,18 +202,18 @@ def json_writer(manual_name: str, output: dict) -> None:
252202
m_anna_heatpump_cooling = base.copy()
253203

254204
# Go for 1cbf
255-
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"][
256-
"model"
257-
] = "Generic heater/cooler"
258-
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"][
259-
"binary_sensors"
260-
]["cooling_enabled"] = True
261-
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"][
262-
"binary_sensors"
263-
]["heating_state"] = False
264-
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"][
265-
"binary_sensors"
266-
]["cooling_state"] = True
205+
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"]["model"] = (
206+
"Generic heater/cooler"
207+
)
208+
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"]["binary_sensors"][
209+
"cooling_enabled"
210+
] = True
211+
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"]["binary_sensors"][
212+
"heating_state"
213+
] = False
214+
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"]["binary_sensors"][
215+
"cooling_state"
216+
] = True
267217

268218
m_anna_heatpump_cooling["1cbf783bb11e4a7c8a6843dee3a86927"]["sensors"][
269219
"water_temperature"
@@ -344,9 +294,9 @@ def json_writer(manual_name: str, output: dict) -> None:
344294

345295
# Go for 3cb7
346296
m_anna_heatpump_idle["3cb70739631c4d17a86b8b12e8a5161b"]["control_state"] = "idle"
347-
m_anna_heatpump_idle["3cb70739631c4d17a86b8b12e8a5161b"]["sensors"][
348-
"temperature"
349-
] = 23.0
297+
m_anna_heatpump_idle["3cb70739631c4d17a86b8b12e8a5161b"]["sensors"]["temperature"] = (
298+
23.0
299+
)
350300
m_anna_heatpump_idle["3cb70739631c4d17a86b8b12e8a5161b"]["sensors"][
351301
"cooling_activation_outdoor_temperature"
352302
] = 25.0

scripts/run-in-env.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
# 20250613 Copied from HA-Core (unchanged)
23
set -eu
34

4-
my_path=$(git rev-parse --show-toplevel)
5+
# Used in venv activate script.
6+
# Would be an error if undefined.
7+
OSTYPE="${OSTYPE-}"
58

6-
# shellcheck disable=SC1091
7-
. "${my_path}/scripts/python-venv.sh"
9+
# Activate pyenv and virtualenv if present, then run the specified command
810

9-
# shellcheck disable=SC2154
10-
if [ -f "${my_venv}/bin/activate" ]; then
11-
set +o nounset # Workaround https://github.com/pypa/virtualenv/issues/150 for nodeenv
12-
# shellcheck disable=SC1091
13-
. "${my_venv}/bin/activate"
14-
set -o nounset
15-
exec "$@"
11+
# pyenv, pyenv-virtualenv
12+
if [ -s .python-version ]; then
13+
PYENV_VERSION=$(head -n 1 .python-version)
14+
export PYENV_VERSION
15+
fi
16+
17+
if [ -n "${VIRTUAL_ENV-}" ] && [ -f "${VIRTUAL_ENV}/bin/activate" ]; then
18+
. "${VIRTUAL_ENV}/bin/activate"
1619
else
17-
echo "Virtualenv available, bailing out"
18-
exit 2
20+
# other common virtualenvs
21+
my_path=$(git rev-parse --show-toplevel)
22+
23+
for venv in venv .venv .; do
24+
if [ -f "${my_path}/${venv}/bin/activate" ]; then
25+
. "${my_path}/${venv}/bin/activate"
26+
break
27+
fi
28+
done
1929
fi
30+
31+
exec "$@"

scripts/setup.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
#!/usr/bin/env bash
2-
set -eu
2+
# 20250613 Copied from HA-core and adjusted
3+
set -e
34

45
my_path=$(git rev-parse --show-toplevel)
56

6-
# shellcheck disable=SC1091
7-
. "${my_path}/scripts/python-venv.sh"
7+
if [ ! -n "$VIRTUAL_ENV" ]; then
8+
if [ -x "$(command -v uv)" ]; then
9+
uv venv venv
10+
else
11+
python3 -m venv venv
12+
fi
13+
source venv/bin/activate
14+
fi
815

9-
# shellcheck disable=SC2154
10-
if [ -f "${my_venv}/bin/activate" ]; then
11-
set +o nounset # Workaround https://github.com/pypa/virtualenv/issues/150 for nodeenv
12-
# shellcheck disable=SC1091
13-
. "${my_venv}/bin/activate"
14-
set -o nounset
15-
# Install commit requirements
16-
pip install wheel uv
17-
uv pip install --upgrade -e . -r requirements_commit.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_pre_commit.txt
18-
# Install pre-commit hook
19-
"${my_venv}/bin/pre-commit" install
20-
else
21-
echo "Virtualenv available, bailing out"
22-
exit 2
16+
if ! [ -x "$(command -v uv)" ]; then
17+
python3 -m pip install uv
2318
fi
19+
20+
# Install commit requirements
21+
uv pip install --upgrade -e . -r requirements_commit.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_pre_commit.txt
22+
23+
# Install pre-commit hook
24+
pre-commit install

0 commit comments

Comments
 (0)