mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Add task to install all requirements of an integration (#108262)
* Add task to install the requirements of an integration * Gather recursive requirements * Move valid_integration to util * Apply suggestions from code review Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> * Implement suggestions --------- Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
54
script/install_integration_requirements.py
Normal file
54
script/install_integration_requirements.py
Normal file
@ -0,0 +1,54 @@
|
||||
"""Install requirements for a given integration."""
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .gen_requirements_all import gather_recursive_requirements
|
||||
from .util import valid_integration
|
||||
|
||||
|
||||
def get_arguments() -> argparse.Namespace:
|
||||
"""Get parsed passed in arguments."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Install requirements for a given integration"
|
||||
)
|
||||
parser.add_argument(
|
||||
"integration", type=valid_integration, help="Integration to target."
|
||||
)
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
return arguments
|
||||
|
||||
|
||||
def main() -> int | None:
|
||||
"""Install requirements for a given integration."""
|
||||
if not Path("requirements_all.txt").is_file():
|
||||
print("Run from project root")
|
||||
return 1
|
||||
|
||||
args = get_arguments()
|
||||
|
||||
requirements = gather_recursive_requirements(args.integration)
|
||||
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
"-c",
|
||||
"homeassistant/package_constraints.txt",
|
||||
"-U",
|
||||
*requirements,
|
||||
]
|
||||
print(" ".join(cmd))
|
||||
subprocess.run(
|
||||
cmd,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
Reference in New Issue
Block a user