diff --git a/BaseTools/Tests/RunTests.py b/BaseTools/Tests/RunTests.py index 81af736cd8..e8acf1b348 100644 --- a/BaseTools/Tests/RunTests.py +++ b/BaseTools/Tests/RunTests.py @@ -12,14 +12,6 @@ import os import sys import unittest - -try: - import distutils.util -except ModuleNotFoundError: - sys.exit(''' -Python reported: "No module named 'distutils.util" -''') - import TestTools def GetCTestSuite(): diff --git a/edksetup.sh b/edksetup.sh index c7b2e1e201..ed9ceae85d 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -177,11 +177,22 @@ function SetupPython() SetupPython3 } +function TestUtilModule() +{ + if ( $PYTHON_COMMAND -c "import distutils.util" >/dev/null 2>&1 );then + return 1 + else + echo Error: "No module named 'distutils.util" + return 0 + fi +} + function SourceEnv() { SetWorkspace && - SetupEnv - SetupPython + SetupEnv && + SetupPython && + TestUtilModule } I=$#