3 # Copyright 2018 Espressif Systems (Shanghai) PTE LTD
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
23 print('pkg_resources cannot be imported probably because the pip package is not installed and/or using a '
24 'legacy Python interpreter. Please refer to the Get Started section of the ESP-IDF Programming Guide for '
25 'setting up the required packages.')
28 if __name__ == "__main__":
29 idf_path = os.getenv("IDF_PATH")
31 parser = argparse.ArgumentParser(description='ESP32 Python package dependency checker')
32 parser.add_argument('--requirements', '-r',
33 help='Path to the requrements file',
34 default=idf_path + '/requirements.txt')
35 args = parser.parse_args()
37 # Special case for MINGW32 Python, needs some packages
38 # via MSYS2 not via pip or system breaks...
39 if sys.platform == "win32" and \
40 os.environ.get("MSYSTEM", None) == "MINGW32" and \
41 "/mingw32/bin/python" in sys.executable:
46 print("Please run the following command to install MSYS2's MINGW Python cryptography package:")
47 print("pacman -S mingw-w64-i686-python%d-cryptography" % (sys.version_info[0],))
52 print("Please run the following command to install MSYS2's MINGW Python setuptools package:")
53 print("pacman -S mingw-w64-i686-python%d-setuptools" % (sys.version_info[0],))
59 with open(args.requirements) as f:
63 pkg_resources.require(line)
65 not_satisfied.append(line)
67 if len(not_satisfied) > 0:
68 print('The following Python requirements are not satisfied:')
69 for requirement in not_satisfied:
71 print('Please run "{} -m pip install --user -r {}" for resolving the issue.'.format(sys.executable, args.requirements))
74 print('Python requirements from {} are satisfied.'.format(args.requirements))