Check included packages.
39def check_included_packages() -> list[str]:
40 """!
41 @brief Check included packages
42 @return status if included packages are okay
43 """
44 d_third_party = {}
45 d_buildin = {}
46 d_own_packs = {}
47
48
49 regex_third_party = re.compile(r".venv\/lib\/site-packages.*.py", re.IGNORECASE)
50 regex_third_party_name = re.compile(r"(?<=site-packages\/).*", re.IGNORECASE)
51 regex_builtin = re.compile(r".venv\/lib\/.*.py", re.IGNORECASE)
52 regex_builtin_name = re.compile(r"(?<=lib\/).*", re.IGNORECASE)
53 regex_own_packs = re.compile(fr"{__title__}\/.*")
54
55
56 with open(S_RELATIVE_PATH, mode="r", encoding="utf-8") as o_html_file:
57 soup = BeautifulSoup(o_html_file, "html.parser")
58
59
60 l_nodes = soup.find_all("div", class_="node")
61 for o_node in l_nodes:
62 l_targets = o_node.find_all("a", target="code")
63 for o_target in l_targets:
64 s_package_path = o_target["href"]
65 if regex_third_party.search(s_package_path):
66 matches = regex_third_party_name.search(s_package_path)
67 if matches is not None:
68 d_third_party[matches.group().split("/", maxsplit=1)[0].replace(".py", "")] = ""
69 elif regex_builtin.search(s_package_path):
70 matches = regex_builtin_name.search(s_package_path)
71 if matches is not None:
72 d_buildin[matches.group().replace(".py", "")] = ""
73 elif regex_own_packs.search(s_package_path):
74 matches = regex_own_packs.search(s_package_path)
75 if matches is not None:
76 d_own_packs[matches.group()] = ""
77
78
79 log.debug("\nThird party packages:")
80 log.debug("\n".join(list(d_third_party.keys())))
81 log.debug("\nOwn packages:")
82 log.debug("\n".join(list(d_own_packs.keys())))
83 log.debug("\nPython buildin packages:")
84 log.debug("\n".join(list(d_buildin.keys())))
85
86
87 l_not_allowed_packages = []
88 for s_package in list(d_third_party.keys()):
89 if s_package not in L_ALLOWED_THIRD_PARTY_PACKAGES:
90 l_not_allowed_packages.append(f"ERROR PyInstaller included an unknown package in the executable: \'{s_package}\'")
91 return l_not_allowed_packages