-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate_lite_toml.py
More file actions
42 lines (33 loc) · 1.26 KB
/
Copy pathgenerate_lite_toml.py
File metadata and controls
42 lines (33 loc) · 1.26 KB
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
from typing import Any
import toml
def generate_lite() -> None:
"""Generates the mindee-lite version of pyproject.toml"""
with open("pyproject.toml", encoding="utf-8") as file_data:
data: dict[str, Any] = toml.load(file_data)
data["project"]["name"] = "mindee-lite"
data["project"]["description"] = (
"Mindee API helper library for Python (Lite Version)"
)
original_deps = data["project"]["dependencies"]
heavy_deps = [
dep
for dep in original_deps
if str(dep).lower().startswith("pillow")
or str(dep).lower().startswith("pypdfium2")
]
lite_deps = [
dep
for dep in original_deps
if not str(dep).lower().startswith("pillow")
and not str(dep).lower().startswith("pypdfium2")
]
data["project"]["optional-dependencies"]["heavy"] = heavy_deps
data["project"]["dependencies"] = lite_deps
data["tool"]["pytest"]["ini_options"]["addopts"] = data["tool"]["pytest"][
"ini_options"
]["addopts"].replace(" lite", " pypdfium2 and not pillow")
with open("pyproject-lite.toml", "w", encoding="utf-8") as file_data:
toml.dump(data, file_data)
print("Successfully generated pyproject-lite.toml")
if __name__ == "__main__":
generate_lite()