-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-missing-reqs.py
69 lines (60 loc) · 1.92 KB
/
check-missing-reqs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import subprocess
import argparse
import sys
from pathlib import Path
def run_check(source_dir, requirements_file, ignore_paths):
command = ["pip-missing-reqs", source_dir, "--requirements-file", requirements_file]
for path in ignore_paths:
command.extend(["-f", path])
print(f"\n🔍 Checking for missing requirements in {source_dir}")
print(f"Using requirements file: {requirements_file}")
print(f"Ignoring paths: {', '.join(ignore_paths)}\n")
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"❌ pip-missing-reqs exited with code {e.returncode}")
sys.exit(e.returncode)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description="Check for unused/missing Python requirements."
)
parser.add_argument(
"--lambda-name",
choices=["tweet", "youtube"],
required=True,
help="Specify which Lambda to check requirements for.",
)
args = parser.parse_args()
if args.lambda_name == "tweet":
run_check(
source_dir=".",
requirements_file="tweet_lambda_requirements.txt",
ignore_paths=[
"venv-tweet",
"tests",
"__pycache__",
".pytest_cache",
".mypy_cache",
".git",
".venv",
"terraform",
"images",
],
)
elif args.lambda_name == "youtube":
run_check(
source_dir=".",
requirements_file="youtube_lambda_requirements.txt",
ignore_paths=[
"venv-youtube",
"tests",
"__pycache__",
".pytest_cache",
".mypy_cache",
".git",
".venv",
"terraform",
"images",
],
)