mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Let renovate update the lock file
This commit is contained in:
+2
-3
@@ -18,8 +18,7 @@ homeassistant/generated/*.py linguist-generated=true
|
||||
pylint/plugins/pylint_home_assistant/generated/*.py linguist-generated=true
|
||||
machine/* linguist-generated=true
|
||||
mypy.ini linguist-generated=true
|
||||
requirements.txt linguist-generated=true
|
||||
requirements_all.txt linguist-generated=true
|
||||
requirements_test_pre_commit.txt linguist-generated=true
|
||||
requirements*.txt linguist-generated=true
|
||||
requirements_*.lock linguist-generated=true
|
||||
script/hassfest/docker/Dockerfile linguist-generated=true
|
||||
.github/workflows/*.lock.yml linguist-generated=true
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"enabledManagers": [
|
||||
"pep621",
|
||||
"pip_requirements",
|
||||
"pip-compile",
|
||||
"pre-commit",
|
||||
"dockerfile",
|
||||
"custom.regex",
|
||||
@@ -22,6 +23,10 @@
|
||||
]
|
||||
},
|
||||
|
||||
"pip-compile": {
|
||||
"managerFilePatterns": ["/(^|/)requirements[\\w_-]*\\.lock$/"]
|
||||
},
|
||||
|
||||
"dockerfile": {
|
||||
"managerFilePatterns": ["/^Dockerfile$/"]
|
||||
},
|
||||
|
||||
@@ -94,6 +94,14 @@ dependencies = [
|
||||
[project.scripts]
|
||||
hass = "homeassistant.__main__:main"
|
||||
|
||||
[tool.uv]
|
||||
# Constrain the universal `uv pip compile` resolution (used for the .lock files)
|
||||
# to the platforms Home Assistant actually targets: Linux and macOS.
|
||||
environments = [
|
||||
"sys_platform == 'linux'",
|
||||
# "sys_platform == 'darwin'",
|
||||
]
|
||||
|
||||
[tool.setuptools]
|
||||
include-package-data = true
|
||||
|
||||
|
||||
Generated
+1617
-1603
File diff suppressed because it is too large
Load Diff
Generated
+1
-1
@@ -1,5 +1,5 @@
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# Automatically generated by gen_requirements_all.py, do not edit
|
||||
# uv pip compile --generate-hashes --output-file requirements_ci.lock requirements_all.txt requirements_test.txt
|
||||
accuweather==5.1.0 \
|
||||
--hash=sha256:87e7e62760c7afbd217d3fcca358e53765aa000df524ec15a5d17cebb1a28b61 \
|
||||
--hash=sha256:da048af53e67392e8eb2666822f6f2b5d3d3a0232c88dbc04050678a75e9543c
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate updated constraint and requirements files."""
|
||||
|
||||
from collections.abc import Sequence
|
||||
import difflib
|
||||
import importlib
|
||||
from operator import itemgetter
|
||||
@@ -244,9 +245,9 @@ coloredlogs==15.0.1
|
||||
setuptools==81.0.0
|
||||
"""
|
||||
|
||||
GENERATED_MESSAGE = f"Automatically generated by {Path(__file__).name}, do not edit"
|
||||
|
||||
GENERATED_MESSAGE_AS_COMMENT = f"# {GENERATED_MESSAGE}\n\n"
|
||||
GENERATED_MESSAGE = (
|
||||
f"# Automatically generated by {Path(__file__).name}, do not edit\n\n"
|
||||
)
|
||||
|
||||
MAP_HOOK_ID_TO_PACKAGE = {
|
||||
"ruff-check": "ruff",
|
||||
@@ -465,7 +466,7 @@ def generate_action_requirements_list(reqs: dict[str, list[str]], action: str) -
|
||||
def requirements_output() -> str:
|
||||
"""Generate output for requirements."""
|
||||
output = [
|
||||
GENERATED_MESSAGE_AS_COMMENT,
|
||||
GENERATED_MESSAGE,
|
||||
"-c homeassistant/package_constraints.txt\n",
|
||||
"\n",
|
||||
"# Home Assistant Core\n",
|
||||
@@ -485,7 +486,7 @@ def requirements_all_output(reqs: dict[str, list[str]]) -> str:
|
||||
"""Generate output for requirements_all."""
|
||||
output = [
|
||||
"# Home Assistant Core, full dependency set\n",
|
||||
GENERATED_MESSAGE_AS_COMMENT,
|
||||
GENERATED_MESSAGE,
|
||||
"-r requirements.txt\n",
|
||||
]
|
||||
output.append(generate_requirements_list(reqs))
|
||||
@@ -497,7 +498,7 @@ def requirements_all_action_output(reqs: dict[str, list[str]], action: str) -> s
|
||||
"""Generate output for requirements_all_{action}."""
|
||||
output = [
|
||||
f"# Home Assistant Core, full dependency set for {action}\n",
|
||||
GENERATED_MESSAGE_AS_COMMENT,
|
||||
GENERATED_MESSAGE,
|
||||
"-r requirements.txt\n",
|
||||
]
|
||||
output.append(generate_action_requirements_list(reqs, action))
|
||||
@@ -531,7 +532,7 @@ def requirements_pre_commit_output() -> str:
|
||||
def gather_constraints() -> str:
|
||||
"""Construct output for constraint file."""
|
||||
return (
|
||||
GENERATED_MESSAGE_AS_COMMENT
|
||||
GENERATED_MESSAGE
|
||||
+ "\n".join(
|
||||
[
|
||||
*sorted(
|
||||
@@ -549,24 +550,40 @@ def gather_constraints() -> str:
|
||||
)
|
||||
|
||||
|
||||
def diff_file(filename: str, content: str) -> list[str]:
|
||||
"""Diff a file."""
|
||||
def diff_content(
|
||||
content_a: Sequence[str], filename_a: str, content_b: Sequence[str], filename_b: str
|
||||
) -> list[str]:
|
||||
"""Diff two strings as if they were files."""
|
||||
return list(
|
||||
difflib.context_diff(
|
||||
[f"{line}\n" for line in Path(filename).read_text().split("\n")],
|
||||
[f"{line}\n" for line in content.split("\n")],
|
||||
filename,
|
||||
"generated",
|
||||
content_a,
|
||||
content_b,
|
||||
filename_a,
|
||||
filename_b,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def diff_file(filename: str, content: str) -> list[str]:
|
||||
"""Diff a file."""
|
||||
return diff_content(
|
||||
[f"{line}\n" for line in Path(filename).read_text().split("\n")],
|
||||
filename,
|
||||
[f"{line}\n" for line in content.split("\n")],
|
||||
"generated",
|
||||
)
|
||||
|
||||
|
||||
def generate_lock_file(output_path: str, source_files: tuple[str, ...]) -> None:
|
||||
"""Resolve requirements_all.txt into a hash-pinned lock file.
|
||||
|
||||
This shells out to `uv pip compile --generate-hashes`, which performs a
|
||||
full networked dependency resolution, so callers should only invoke it
|
||||
when requirements/dependencies have changed.
|
||||
|
||||
uv records its invocation in the lock file header, which lets Renovate's
|
||||
pip-compile manager parse and re-run it to refresh the lock file when it
|
||||
bumps a dependency.
|
||||
"""
|
||||
subprocess.run(
|
||||
[
|
||||
@@ -575,10 +592,9 @@ def generate_lock_file(output_path: str, source_files: tuple[str, ...]) -> None:
|
||||
"compile",
|
||||
"--generate-hashes",
|
||||
"--quiet",
|
||||
"--universal",
|
||||
"--output-file",
|
||||
output_path,
|
||||
"--custom-compile-command",
|
||||
GENERATED_MESSAGE,
|
||||
*source_files,
|
||||
],
|
||||
check=True,
|
||||
@@ -630,9 +646,22 @@ def main(validate: bool, ci: bool) -> int:
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
for lock_file, source_files in PIP_COMPILE_LOCK_FILES.items():
|
||||
tmp_lock = str(Path(tmp_dir) / lock_file)
|
||||
# The header contains the generated command, which we need to ignore when comparing the existing lock file with the generated one due the tempoary folder used for generation.
|
||||
lock_content = [
|
||||
f"{line}\n"
|
||||
for line in Path(lock_file).read_text(encoding="utf-8").split("\n")
|
||||
][1:]
|
||||
|
||||
generate_lock_file(tmp_lock, source_files)
|
||||
lock_diff = diff_file(
|
||||
lock_file, Path(tmp_lock).read_text(encoding="utf-8")
|
||||
generated_lock_content = [
|
||||
f"{line}\n"
|
||||
for line in Path(tmp_lock).read_text(encoding="utf-8").split("\n")
|
||||
][1:]
|
||||
lock_diff = diff_content(
|
||||
lock_content,
|
||||
lock_file,
|
||||
generated_lock_content,
|
||||
"generated",
|
||||
)
|
||||
if lock_diff:
|
||||
errors.append("".join(lock_diff))
|
||||
|
||||
Reference in New Issue
Block a user