Merge branch 'bugfix/win_path_print' into 'master'

tools: correct printed path on MS Win

See merge request idf/esp-idf!3853
This commit is contained in:
Angus Gratton 2018-12-06 07:18:32 +08:00
commit ff71ea9202
2 changed files with 17 additions and 9 deletions

View file

@ -203,7 +203,6 @@ exclude =
examples/system/ota/otatool/example_test.py,
examples/wifi/iperf/iperf_test.py,
examples/wifi/iperf/test_report.py,
tools/check_python_dependencies.py,
tools/ci/apply_bot_filter.py,
tools/cmake/convert_to_cmake.py,
tools/esp_app_trace/apptrace_proc.py,

View file

@ -19,19 +19,28 @@ import sys
import argparse
try:
import pkg_resources
except:
except Exception:
print('pkg_resources cannot be imported probably because the pip package is not installed and/or using a '
'legacy Python interpreter. Please refer to the Get Started section of the ESP-IDF Programming Guide for '
'setting up the required packages.')
'setting up the required packages.')
sys.exit(1)
def escape_backslash(path):
if sys.platform == "win32":
# escaped backslashes are necessary in order to be able to copy-paste the printed path
return path.replace("\\", "\\\\")
else:
return path
if __name__ == "__main__":
idf_path = os.getenv("IDF_PATH")
parser = argparse.ArgumentParser(description='ESP32 Python package dependency checker')
parser.add_argument('--requirements', '-r',
help='Path to the requrements file',
default=idf_path + '/requirements.txt')
help='Path to the requrements file',
default=os.path.join(idf_path, 'requirements.txt'))
args = parser.parse_args()
# Special case for MINGW32 Python, needs some packages
@ -41,13 +50,13 @@ if __name__ == "__main__":
"/mingw32/bin/python" in sys.executable:
failed = False
try:
import cryptography
import cryptography # noqa: intentionally not used - imported for testing its availability
except ImportError:
print("Please run the following command to install MSYS2's MINGW Python cryptography package:")
print("pacman -Sy mingw-w64-i686-python%d-cryptography" % (sys.version_info[0],))
failed = True
try:
import setuptools
import setuptools # noqa: intentionally not used - imported for testing its availability
except ImportError:
print("Please run the following command to install MSYS2's MINGW Python setuptools package:")
print("pacman -Sy mingw-w64-i686-python%d-setuptools" % (sys.version_info[0],))
@ -61,7 +70,7 @@ if __name__ == "__main__":
line = line.strip()
try:
pkg_resources.require(line)
except:
except Exception:
not_satisfied.append(line)
if len(not_satisfied) > 0:
@ -70,7 +79,7 @@ if __name__ == "__main__":
print(requirement)
print('Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required '
'packages. Alternatively, you can run "{} -m pip install --user -r {}" for resolving the issue.'
''.format(sys.executable, args.requirements))
''.format(escape_backslash(sys.executable), escape_backslash(args.requirements)))
sys.exit(1)
print('Python requirements from {} are satisfied.'.format(args.requirements))