|
1 | | -"""Install requirements for a given integration.""" |
| 1 | +"""Install requirements for one or more integrations.""" |
2 | 2 |
|
3 | 3 | import argparse |
4 | 4 | from pathlib import Path |
|
12 | 12 | def get_arguments() -> argparse.Namespace: |
13 | 13 | """Get parsed passed in arguments.""" |
14 | 14 | parser = argparse.ArgumentParser( |
15 | | - description="Install requirements for a given integration" |
| 15 | + description="Install requirements for one or more integrations" |
16 | 16 | ) |
17 | 17 | parser.add_argument( |
18 | | - "integration", type=valid_integration, help="Integration to target." |
| 18 | + "integrations", |
| 19 | + nargs="+", |
| 20 | + type=valid_integration, |
| 21 | + help="Integration(s) to target.", |
19 | 22 | ) |
20 | 23 |
|
21 | 24 | return parser.parse_args() |
22 | 25 |
|
23 | 26 |
|
24 | 27 | def main() -> int | None: |
25 | | - """Install requirements for a given integration.""" |
| 28 | + """Install requirements for the specified integrations.""" |
26 | 29 | if not Path("requirements_all.txt").is_file(): |
27 | 30 | print("Run from project root") |
28 | 31 | return 1 |
29 | 32 |
|
30 | 33 | args = get_arguments() |
31 | 34 |
|
32 | | - requirements = gather_recursive_requirements(args.integration) |
33 | | - |
34 | | - cmd = [ |
35 | | - "uv", |
36 | | - "pip", |
37 | | - "install", |
38 | | - "-c", |
39 | | - "homeassistant/package_constraints.txt", |
40 | | - "-U", |
41 | | - *requirements, |
42 | | - ] |
43 | | - print(" ".join(cmd)) |
44 | | - subprocess.run( |
45 | | - cmd, |
46 | | - check=True, |
47 | | - ) |
| 35 | + # Gather requirements for all specified integrations |
| 36 | + all_requirements = set() |
| 37 | + for integration in args.integrations: |
| 38 | + requirements = gather_recursive_requirements(integration) |
| 39 | + all_requirements.update(requirements) |
| 40 | + |
| 41 | + if all_requirements: |
| 42 | + cmd = [ |
| 43 | + "uv", |
| 44 | + "pip", |
| 45 | + "install", |
| 46 | + "-c", |
| 47 | + "homeassistant/package_constraints.txt", |
| 48 | + "-U", |
| 49 | + *sorted(all_requirements), # Sort for consistent output |
| 50 | + ] |
| 51 | + print(" ".join(cmd)) |
| 52 | + subprocess.run( |
| 53 | + cmd, |
| 54 | + check=True, |
| 55 | + ) |
| 56 | + else: |
| 57 | + print("No requirements to install.") |
48 | 58 | return None |
49 | 59 |
|
50 | 60 |
|
|
0 commit comments