tools: Check project requirements

This commit is contained in:
Matt Borgerson 2023-07-07 02:05:14 -07:00 committed by mborgerson
parent 69607f62d2
commit 21bc641df6
5 changed files with 48 additions and 3 deletions

View File

@ -1,3 +1,3 @@
libclang
pefile
pyxbe
libclang~=16.0.0
pefile~=2023.2.7
pyxbe~=1.0.2

View File

@ -0,0 +1,33 @@
from pathlib import Path
import logging
import pkg_resources
import color
log = logging.getLogger(__name__)
def check_requirements() -> None:
requirements_path = Path(__file__).parent.with_name("requirements.txt")
with open(requirements_path, "r", encoding="utf-8") as f:
requirements = f.readlines()
try:
pkg_resources.require(requirements)
except pkg_resources.DistributionNotFound as e:
log.error("Required package '%s' is not installed. Please install project requirements via requirements.txt.", e.req)
exit(1)
except pkg_resources.VersionConflict as e:
log.error("There is a package version conflict. '%s' is installed, but '%s' is required. Please install project requirements via requirements.txt.", e.dist, e.req)
exit(1)
def main():
check_requirements()
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, handlers=[color.ColorLogHandler()])
main()

View File

@ -1,4 +1,8 @@
#!/usr/bin/env python3
if __name__ == "__main__":
from check_requirements import check_requirements
check_requirements()
import json
from collections import defaultdict
from typing import Sequence, Union, Optional

View File

@ -1,4 +1,8 @@
#!/usr/bin/env python3
if __name__ == "__main__":
from check_requirements import check_requirements
check_requirements()
import argparse
import logging
import os

View File

@ -1,4 +1,8 @@
#!/usr/bin/env python3
if __name__ == "__main__":
from check_requirements import check_requirements
check_requirements()
import itertools
import struct
import subprocess