-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_tweet_requirements.py
45 lines (36 loc) · 1.26 KB
/
generate_tweet_requirements.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
from pathlib import Path
# Adjust paths for new structure
base_dir = Path(__file__).parent / "lambdas" / "tweet"
dev_filename = base_dir / "tweet_lambda_requirements-dev.txt"
prod_filename = base_dir / "tweet_lambda_requirements.txt"
# Dev-only dependencies to exclude from the production file
dev_only_deps = {
"boto3",
"botocore",
"pytest",
"iniconfig",
"pluggy",
"jmespath",
"packaging",
"pip-check-reqs",
}
def regenerate_prod_requirements(dev_path: Path, prod_path: Path, exclude_deps: set):
with dev_path.open("r") as f:
lines = f.readlines()
# Strip dev-only packages and comments/blank lines
prod_lines = []
for line in lines:
line = line.strip()
if not line or line.startswith("#") or line.startswith("-r"):
continue
pkg_name = line.split("==")[0].lower()
if pkg_name not in exclude_deps:
prod_lines.append(line)
with prod_path.open("w") as f:
f.write("\n".join(prod_lines) + "\n")
print(
f"✅ Regenerated {prod_path.name} with {len(prod_lines)} production packages "
f"(excluded {len(exclude_deps)} dev packages)."
)
if __name__ == "__main__":
regenerate_prod_requirements(dev_filename, prod_filename, dev_only_deps)