Adding a top-level runtime python dependency checker. Goal is to

provide a kinder error message in the case where python dependencies
are not available locally. This is motivated for future execution by
users who are running from rocm-based binary packaging instead of using
normal cmake build system which would have verified the dependencies.

Signed-off-by: Karl W. Schulz <karl.schulz@amd.com>
This commit is contained in:
Karl W. Schulz
2024-05-03 12:21:22 -05:00
کامیت شده توسط Cole Ramos
والد 80c93aa452
کامیت d1ee2ec870
+58 -3
مشاهده پرونده
@@ -24,13 +24,67 @@
# SOFTWARE.
##############################################################################el
import sys
import logging
from omniperf_base import Omniperf
from utils.utils import console_error
import os
import sys
import pkg_resources
from pathlib import Path
from pkg_resources import DistributionNotFound, VersionConflict
from distutils import text_file
try:
from omniperf_base import Omniperf
from utils.utils import console_error
except:
pass
def verify_deps():
bindir = Path(__file__).resolve().parent
depsLocation = ["requirements.txt", "../requirements.txt"]
for location in depsLocation:
checkFile = os.path.join(bindir, location)
if os.path.exists(checkFile):
dependencies = text_file.TextFile(checkFile).readlines()
error = False
try:
pkg_resources.require(dependencies)
except DistributionNotFound as e:
print(
"[ERROR] The '%s' distribution was not found in the current execution environment."
% e.req.key
)
error = True
except VersionConflict as e:
print(
"[ERROR] the '%s' distribution does not meet version requirements to use omniperf."
% e.req.key
)
print(" --> version installed :", e.dist)
print(" --> version required :", e.req)
error = True
if error:
print("")
print(
"Please verify all of the python dependencies called out in the requirements file"
)
print("are installed locally prior to running omniperf.")
print("")
print("See: %s" % checkFile)
sys.exit(1)
return
def main():
# verify required python dependencies
verify_deps()
omniperf = Omniperf()
mode = omniperf.get_mode()
@@ -47,5 +101,6 @@ def main():
sys.exit(0)
if __name__ == "__main__":
main()