2024-01-18 21:11:02 +00:00
|
|
|
"""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."
|
|
|
|
)
|
|
|
|
|
2024-04-06 09:07:37 +00:00
|
|
|
return parser.parse_args()
|
2024-01-18 21:11:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 = [
|
2024-05-21 07:56:31 +00:00
|
|
|
"uv",
|
2024-01-18 21:11:02 +00:00
|
|
|
"pip",
|
|
|
|
"install",
|
|
|
|
"-c",
|
|
|
|
"homeassistant/package_constraints.txt",
|
|
|
|
"-U",
|
|
|
|
*requirements,
|
|
|
|
]
|
|
|
|
print(" ".join(cmd))
|
|
|
|
subprocess.run(
|
|
|
|
cmd,
|
|
|
|
check=True,
|
|
|
|
)
|
2024-07-30 14:57:42 +00:00
|
|
|
return None
|
2024-01-18 21:11:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|