def check_environment(): """ Verify the environment contains the top-level tools we need to operate (cmake will check a lot of other things) """ checks_output = [] if not executable_exists(['cmake', '--version']): debug_print_idf_version() raise FatalError("'cmake' must be available on the PATH to use %s" % PROG) # verify that IDF_PATH env variable is set # find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH detected_idf_path = realpath(os.path.join(os.path.dirname(__file__), '..')) if 'IDF_PATH' in os.environ: set_idf_path = realpath(os.environ['IDF_PATH']) if set_idf_path != detected_idf_path: print_warning( 'WARNING: IDF_PATH environment variable is set to %s but %s path indicates IDF directory %s. ' 'Using the environment variable directory, but results may be unexpected...' % (set_idf_path, PROG, detected_idf_path)) else: print_warning('Setting IDF_PATH environment variable: %s' % detected_idf_path) os.environ['IDF_PATH'] = detected_idf_path # check Python version if sys.version_info[0] < 3: print_warning( 'WARNING: Support for Python 2 is deprecated and will be removed in future versions.' ) elif sys.version_info[0] == 3 and sys.version_info[1] < 6: print_warning( 'WARNING: Python 3 versions older than 3.6 are not supported.') # check Python dependencies checks_output.append('Checking Python dependencies...') try: out = subprocess.check_output( [ os.environ['PYTHON'], os.path.join(os.environ['IDF_PATH'], 'tools', 'check_python_dependencies.py'), ], env=os.environ, ) checks_output.append(out.decode('utf-8', 'ignore').strip()) except subprocess.CalledProcessError as e: print_warning(e.output.decode('utf-8', 'ignore'), stream=sys.stderr) debug_print_idf_version() raise SystemExit(1) return checks_output
def check_environment(): """ Verify the environment contains the top-level tools we need to operate (cmake will check a lot of other things) """ checks_output = [] if not executable_exists(['cmake', '--version']): debug_print_idf_version() raise FatalError("'cmake' must be available on the PATH to use %s" % PROG) # verify that IDF_PATH env variable is set # find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH detected_idf_path = realpath(os.path.join(os.path.dirname(__file__), '..')) if 'IDF_PATH' in os.environ: set_idf_path = realpath(os.environ['IDF_PATH']) if set_idf_path != detected_idf_path: print_warning( 'WARNING: IDF_PATH environment variable is set to %s but %s path indicates IDF directory %s. ' 'Using the environment variable directory, but results may be unexpected...' % (set_idf_path, PROG, detected_idf_path)) else: print_warning('Setting IDF_PATH environment variable: %s' % detected_idf_path) os.environ['IDF_PATH'] = detected_idf_path try: # The Python compatibility check could have been done earlier (tools/detect_python.{sh,fish}) but PATH is # not set for import at that time. Even if the check would be done before, the same check needs to be done # here as well (for example one can call idf.py from a not properly set-up environment). python_version_checker.check() except RuntimeError as e: raise FatalError(e) # check Python dependencies checks_output.append('Checking Python dependencies...') try: out = subprocess.check_output( [ os.environ['PYTHON'], os.path.join(os.environ['IDF_PATH'], 'tools', 'check_python_dependencies.py'), ], env=os.environ, ) checks_output.append(out.decode('utf-8', 'ignore').strip()) except subprocess.CalledProcessError as e: print_warning(e.output.decode('utf-8', 'ignore'), stream=sys.stderr) debug_print_idf_version() raise SystemExit(1) return checks_output
def check_environment(): """ Verify the environment contains the top-level tools we need to operate (cmake will check a lot of other things) """ checks_output = [] if not executable_exists(["cmake", "--version"]): debug_print_idf_version() raise FatalError("'cmake' must be available on the PATH to use %s" % PROG) # verify that IDF_PATH env variable is set # find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH detected_idf_path = realpath(os.path.join(os.path.dirname(__file__), "..")) if "IDF_PATH" in os.environ: set_idf_path = realpath(os.environ["IDF_PATH"]) if set_idf_path != detected_idf_path: print_warning( "WARNING: IDF_PATH environment variable is set to %s but %s path indicates IDF directory %s. " "Using the environment variable directory, but results may be unexpected..." % (set_idf_path, PROG, detected_idf_path)) else: print_warning("Setting IDF_PATH environment variable: %s" % detected_idf_path) os.environ["IDF_PATH"] = detected_idf_path # check Python dependencies checks_output.append("Checking Python dependencies...") try: out = subprocess.check_output( [ os.environ["PYTHON"], os.path.join(os.environ["IDF_PATH"], "tools", "check_python_dependencies.py"), ], env=os.environ, ) checks_output.append(out.decode('utf-8', 'ignore').strip()) except subprocess.CalledProcessError as e: print_warning(e.output.decode('utf-8', 'ignore'), stream=sys.stderr) debug_print_idf_version() raise SystemExit(1) return checks_output