From a1d0d1ffbe116c0009829163edec65bd28fb3106 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Tue, 9 Nov 2021 13:10:56 +0100 Subject: [PATCH] Tools: Remove MSYS/Mingw support MSYS/Mingw was deprecated since v4.0 and it is removed in v5.0. Please follow the getting started guide of the documentation to set up a Windows Command Line or Power Shell based environment. --- .../en/contribute/install-pre-commit-hook.rst | 5 +- docs/en/contribute/style-guide.rst | 2 +- docs/en/get-started/windows-setup-scratch.rst | 2 +- docs/en/get-started/windows-setup.rst | 1 - docs/zh_CN/get-started/windows-setup.rst | 1 - export.bat | 3 +- install.bat | 3 +- requirements.txt | 10 +-- tools/check_python_dependencies.py | 22 +---- tools/ci/check_copyright_ignore.txt | 1 - tools/ci/mypy_ignore_list.txt | 1 - tools/idf.py | 22 +---- tools/idf_py_actions/constants.py | 27 ++----- tools/idf_py_actions/serial_ext.py | 3 - tools/idf_tools.py | 15 ++-- tools/kconfig_new/esp-windows-curses/setup.py | 31 ------- .../windows/windows_install_prerequisites.sh | 81 ------------------- 17 files changed, 25 insertions(+), 205 deletions(-) delete mode 100644 tools/kconfig_new/esp-windows-curses/setup.py delete mode 100644 tools/windows/windows_install_prerequisites.sh diff --git a/docs/en/contribute/install-pre-commit-hook.rst b/docs/en/contribute/install-pre-commit-hook.rst index b3ced10d06..61d867a837 100644 --- a/docs/en/contribute/install-pre-commit-hook.rst +++ b/docs/en/contribute/install-pre-commit-hook.rst @@ -39,7 +39,7 @@ Common Problems For Windows Users ``/usr/bin/env: python: Permission denied.`` - If you're in Git Bash or MSYS terminal, please check the python executable location by run ``which python``. + If you're in Git Bash, please check the python executable location by run ``which python``. If the executable is under ``~/AppData/Local/Microsoft/WindowsApps/``, then it's a link to Windows AppStore, not a real one. @@ -53,6 +53,3 @@ Your %USERPROFILE% contains non-ASCII characters - CMD: ``set PRE_COMMIT_HOME=C:\somepath\pre-commit`` - PowerShell: ``$Env:PRE_COMMIT_HOME = "C:\somepath\pre-commit"`` - git bash: ``export PRE_COMMIT_HOME="/c/somepath/pre-commit"`` - - - diff --git a/docs/en/contribute/style-guide.rst b/docs/en/contribute/style-guide.rst index 4b0648981f..34e934fbe5 100644 --- a/docs/en/contribute/style-guide.rst +++ b/docs/en/contribute/style-guide.rst @@ -178,7 +178,7 @@ Line Endings Commits should only contain files with LF (Unix style) endings. -Windows users can configure git to check out CRLF (Windows style) endings locally and commit LF endings by setting the ``core.autocrlf`` setting. `Github has a document about setting this option `. However because MSYS2 uses Unix-style line endings, it is often easier to configure your text editor to use LF (Unix style) endings when editing ESP-IDF source files. +Windows users can configure git to check out CRLF (Windows style) endings locally and commit LF endings by setting the ``core.autocrlf`` setting. `Github has a document about setting this option `. If you accidentally have some commits in your branch that add LF endings, you can convert them to Unix by running this command in an MSYS2 or Unix terminal (change directory to the IDF working directory and check the correct branch is currently checked out, beforehand): diff --git a/docs/en/get-started/windows-setup-scratch.rst b/docs/en/get-started/windows-setup-scratch.rst index aec7a95715..9bd482757a 100644 --- a/docs/en/get-started/windows-setup-scratch.rst +++ b/docs/en/get-started/windows-setup-scratch.rst @@ -17,7 +17,7 @@ Get ESP-IDF Previous versions of ESP-IDF used the **MSYS2 bash terminal** command line. The current cmake-based build system can run in the regular **Windows Command Prompt** which is used here. - If you use a bash-based terminal or PowerShell, please note that some command syntax will be different to what is shown below. + If you use PowerShell, please note that some command syntax will be different to what is shown below. Open Command Prompt and run the following commands: diff --git a/docs/en/get-started/windows-setup.rst b/docs/en/get-started/windows-setup.rst index 808012df10..43d9473f63 100644 --- a/docs/en/get-started/windows-setup.rst +++ b/docs/en/get-started/windows-setup.rst @@ -112,7 +112,6 @@ For advanced users who want to customize the install process: windows-setup-update -.. _MSYS2: https://www.msys2.org/ .. _CMake: https://cmake.org/download/ .. _Ninja: https://ninja-build.org/ .. _Python: https://www.python.org/downloads/windows/ diff --git a/docs/zh_CN/get-started/windows-setup.rst b/docs/zh_CN/get-started/windows-setup.rst index f5ef2e9061..06ef9f5a1e 100644 --- a/docs/zh_CN/get-started/windows-setup.rst +++ b/docs/zh_CN/get-started/windows-setup.rst @@ -113,7 +113,6 @@ ESP-IDF 工具安装器可在“开始”菜单中,创建一个打开 ESP-IDF windows-setup-update -.. _MSYS2: https://www.msys2.org/ .. _CMake: https://cmake.org/download/ .. _Ninja: https://ninja-build.org/ .. _Python: https://www.python.org/downloads/windows/ diff --git a/export.bat b/export.bat index 1cfedfc39b..f7f54f676c 100644 --- a/export.bat +++ b/export.bat @@ -1,7 +1,6 @@ @echo off if defined MSYSTEM ( - echo This .bat file is for Windows CMD.EXE shell only. When using MSYS, run: - echo . ./export.sh. + echo This .bat file is for Windows CMD.EXE shell only. goto :eof ) diff --git a/install.bat b/install.bat index df058f1ef1..7dc15be373 100644 --- a/install.bat +++ b/install.bat @@ -1,7 +1,6 @@ @echo off if defined MSYSTEM ( - echo This .bat file is for Windows CMD.EXE shell only. When using MSYS, run: - echo ./install.sh. + echo This .bat file is for Windows CMD.EXE shell only. goto end ) diff --git a/requirements.txt b/requirements.txt index 0907e544f1..45e43877b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,8 +27,6 @@ pygdbmi<=0.9.0.2 # A compatible Socket.IO should be used. See https://github.com/miguelgrinberg/python-socketio/issues/578 python-socketio<5 -kconfiglib==13.7.1 - # esptool requirements (see components/esptool_py/esptool/setup.py) reedsolo>=1.5.3,<=1.5.4 bitstring>=3.1.6 @@ -38,8 +36,6 @@ ecdsa>=0.16.0 # This is the last version supports both 2.7 and 3.4 construct==2.10.54 -# windows-curses are required in Windows command line but cannot be installed in MSYS2. A requirement like -# "windows-curses; sys_platform == 'win32'" would want to install the package on both of them. There is no environment -# marker for detecting MSYS2. So instead, a dummy custom package is used with "windows-curses" dependency for Windows -# command line. -file://${IDF_PATH}/tools/kconfig_new/esp-windows-curses; sys_platform == 'win32' +# kconfig & menuconfig support +kconfiglib==13.7.1 +windows-curses; sys_platform == 'win32' diff --git a/tools/check_python_dependencies.py b/tools/check_python_dependencies.py index 55c1aa26f1..75184943d8 100755 --- a/tools/check_python_dependencies.py +++ b/tools/check_python_dependencies.py @@ -63,31 +63,11 @@ if __name__ == '__main__': elif os.environ.get('IDF_PYTHON_ENV_PATH'): # We are running inside a private virtual environment under IDF_TOOLS_PATH, # ask the user to run install.bat again. - if sys.platform == 'win32' and not os.environ.get('MSYSTEM'): + if sys.platform == 'win32': install_script = 'install.bat' else: install_script = 'install.sh' print('To install the missing packages, please run "%s"' % os.path.join(idf_path, install_script)) # type: ignore - elif sys.platform == 'win32' and os.environ.get('MSYSTEM', None) == 'MINGW32' and '/mingw32/bin/python' in sys.executable: - print("The recommended way to install a packages is via \"pacman\". Please run \"pacman -Ss \" for" - ' searching the package database and if found then ' - "\"pacman -S mingw-w64-i686-python-\" for installing it.") - print("NOTE: You may need to run \"pacman -Syu\" if your package database is older and run twice if the " - "previous run updated \"pacman\" itself.") - print('Please read https://github.com/msys2/msys2/wiki/Using-packages for further information about using ' - "\"pacman\"") - # Special case for MINGW32 Python, needs some packages - # via MSYS2 not via pip or system breaks... - for requirement in not_satisfied: - if requirement.startswith('cryptography'): - print('WARNING: The cryptography package have dependencies on system packages so please make sure ' - "you run \"pacman -Syu\" followed by \"pacman -S mingw-w64-i686-python{}-cryptography\"." - ''.format(sys.version_info[0],)) - continue - elif requirement.startswith('setuptools'): - print("Please run the following command to install MSYS2's MINGW Python setuptools package:") - print('pacman -S mingw-w64-i686-python-setuptools') - continue else: print('Please follow the instructions found in the "Set up the tools" section of ' 'ESP-IDF Getting Started Guide') diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 3822e241fa..95bc18cd8f 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -3625,7 +3625,6 @@ tools/kconfig/qconf.h tools/kconfig/symbol.c tools/kconfig/util.c tools/kconfig_new/confserver.py -tools/kconfig_new/esp-windows-curses/setup.py tools/kconfig_new/gen_kconfig_doc.py tools/kconfig_new/prepare_kconfig_files.py tools/kconfig_new/test/confgen/test_confgen.py diff --git a/tools/ci/mypy_ignore_list.txt b/tools/ci/mypy_ignore_list.txt index 50aa6b313c..b152369024 100644 --- a/tools/ci/mypy_ignore_list.txt +++ b/tools/ci/mypy_ignore_list.txt @@ -226,7 +226,6 @@ tools/idf_py_actions/tools.py tools/idf_py_actions/uf2_ext.py tools/kconfig_new/confgen.py tools/kconfig_new/confserver.py -tools/kconfig_new/esp-windows-curses/setup.py tools/kconfig_new/gen_kconfig_doc.py tools/kconfig_new/prepare_kconfig_files.py tools/kconfig_new/test/confgen/test_confgen.py diff --git a/tools/idf.py b/tools/idf.py index 3e3986ac5e..4e32176c18 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -776,25 +776,9 @@ def _find_usable_locale(): if __name__ == '__main__': try: - # On MSYS2 we need to run idf.py with "winpty" in order to be able to cancel the subprocesses properly on - # keyboard interrupt (CTRL+C). - # Using an own global variable for indicating that we are running with "winpty" seems to be the most suitable - # option as os.environment['_'] contains "winpty" only when it is run manually from console. - WINPTY_VAR = 'WINPTY' - WINPTY_EXE = 'winpty' - if ('MSYSTEM' in os.environ) and (not os.environ.get('_', '').endswith(WINPTY_EXE) - and WINPTY_VAR not in os.environ): - - if 'menuconfig' in sys.argv: - # don't use winpty for menuconfig because it will print weird characters - main() - else: - os.environ[WINPTY_VAR] = '1' # the value is of no interest to us - # idf.py calls itself with "winpty" and WINPTY global variable set - ret = subprocess.call([WINPTY_EXE, sys.executable] + sys.argv, env=os.environ) - if ret: - raise SystemExit(ret) - + if 'MSYSTEM' in os.environ: + print_warning('MSys/Mingw is no longer supported. Please follow the getting started guide of the ' + 'documentation in order to set up a suitiable environment, or continue at your own risk.') elif os.name == 'posix' and not _valid_unicode_config(): # Trying to find best utf-8 locale available on the system and restart python with it best_locale = _find_usable_locale() diff --git a/tools/idf_py_actions/constants.py b/tools/idf_py_actions/constants.py index eadb5653ab..1f217ace38 100644 --- a/tools/idf_py_actions/constants.py +++ b/tools/idf_py_actions/constants.py @@ -3,20 +3,6 @@ import multiprocessing import os import platform -# Make flavors, across the various kinds of Windows environments & POSIX... -if 'MSYSTEM' in os.environ: # MSYS - MAKE_CMD = 'make' - MAKE_GENERATOR = 'MSYS Makefiles' -elif os.name == 'nt': # other Windows - MAKE_CMD = 'mingw32-make' - MAKE_GENERATOR = 'MinGW Makefiles' -elif platform.system() == 'FreeBSD': - MAKE_CMD = 'gmake' - MAKE_GENERATOR = 'Unix Makefiles' -else: - MAKE_CMD = 'make' - MAKE_GENERATOR = 'Unix Makefiles' - GENERATORS = collections.OrderedDict([ # - command: build command line # - version: version command line @@ -28,14 +14,15 @@ GENERATORS = collections.OrderedDict([ 'dry_run': ['ninja', '-n'], 'verbose_flag': '-v' }), - (MAKE_GENERATOR, { - 'command': [MAKE_CMD, '-j', str(multiprocessing.cpu_count() + 2)], - 'version': [MAKE_CMD, '--version'], - 'dry_run': [MAKE_CMD, '-n'], - 'verbose_flag': 'VERBOSE=1', - }) ]) +if os.name != 'nt': + MAKE_CMD = 'gmake' if platform.system() == 'FreeBSD' else 'make' + GENERATORS['Unix Makefiles'] = {'command': [MAKE_CMD, '-j', str(multiprocessing.cpu_count() + 2)], + 'version': [MAKE_CMD, '--version'], + 'dry_run': [MAKE_CMD, '-n'], + 'verbose_flag': 'VERBOSE=1'} + URL_TO_DOC = 'https://docs.espressif.com/projects/esp-idf' SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3'] diff --git a/tools/idf_py_actions/serial_ext.py b/tools/idf_py_actions/serial_ext.py index 585fa4fac5..b78a71e007 100644 --- a/tools/idf_py_actions/serial_ext.py +++ b/tools/idf_py_actions/serial_ext.py @@ -137,9 +137,6 @@ def action_extensions(base_actions, project_path): idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] - if 'MSYSTEM' in os.environ: - monitor_args = ['winpty'] + monitor_args - run_tool('idf_monitor', monitor_args, args.project_dir) def flash(action, ctx, args): diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 5b57c567bd..379408d2d3 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -244,11 +244,6 @@ def to_shell_specific_paths(paths_list): # type: (list[str]) -> list[str] if sys.platform == 'win32': paths_list = [p.replace('/', os.path.sep) if os.path.sep in p else p for p in paths_list] - if 'MSYSTEM' in os.environ: - paths_msys = run_cmd_check_output(['cygpath', '-u', '-f', '-'], - input_text='\n'.join(paths_list)) - paths_list = paths_msys.decode().strip().split('\n') - return paths_list @@ -1257,17 +1252,15 @@ def action_export(args): # type: ignore if idf_tools_dir not in current_path: paths_to_export.append(idf_tools_dir) - if sys.platform == 'win32' and 'MSYSTEM' not in os.environ: + if sys.platform == 'win32': old_path = '%PATH%' path_sep = ';' else: old_path = '$PATH' - # can't trust os.pathsep here, since for Windows Python started from MSYS shell, - # os.pathsep will be ';' path_sep = ':' if args.format == EXPORT_SHELL: - if sys.platform == 'win32' and 'MSYSTEM' not in os.environ: + if sys.platform == 'win32': export_format = 'SET "{}={}"' export_sep = '\n' else: @@ -1819,4 +1812,8 @@ def main(argv): # type: (list[str]) -> None if __name__ == '__main__': + if 'MSYSTEM' in os.environ: + fatal('MSys/Mingw is not supported. Please follow the getting started guide of the documentation to set up ' + 'a supported environment') + raise SystemExit(1) main(sys.argv[1:]) diff --git a/tools/kconfig_new/esp-windows-curses/setup.py b/tools/kconfig_new/esp-windows-curses/setup.py deleted file mode 100644 index 7f23aaab03..0000000000 --- a/tools/kconfig_new/esp-windows-curses/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2019 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http:#www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os - -from setuptools import setup - -setup(name='esp-windows-curses', - version='0.1', - description='Wrapper for the windows-curses package', - url='https://www.espressif.com', - author='Espressif Systems', - license='Apache License 2.0', - author_email='donotreply@espressif.com', - zip_safe=False, - # This wrapper exists only because of the following install_requires statement which ensures that the package - # dependency is not added for MSYS2 where it cannot be installed. There is no PEP 508 environment marker to - # detect MSYS2. - install_requires=('' if 'MSYSTEM' in os.environ else 'windows-curses; sys_platform == "win32"',) - ) diff --git a/tools/windows/windows_install_prerequisites.sh b/tools/windows/windows_install_prerequisites.sh deleted file mode 100644 index 8adcee0468..0000000000 --- a/tools/windows/windows_install_prerequisites.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash -# -# Setup script to configure an MSYS2 environment for ESP-IDF. -# -# Use of this script is optional, there is also a prebuilt MSYS2 environment available -# which can be downloaded and used as-is. -# -# See https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html for full details. - -if [ "$OSTYPE" != "msys" ]; then - echo "This setup script expects to be run from an MSYS2 environment on Windows." - exit 1 -fi -if ! [ -x /bin/pacman ]; then - echo "This setup script expects to use the pacman package manager from MSYS2." - exit 1 -fi -if [ "$MSYSTEM" != "MINGW32" ]; then - echo "This setup script must be started from the 'MSYS2 MinGW 32-bit' start menu shortcut" - echo "OR by running `cygpath -w /mingw32.exe`" - echo "(The current MSYSTEM mode is $MSYSTEM but it expects it to be MINGW32)" - exit 1 -fi - -# if update-core still exists, run it to get the latest core MSYS2 system -# (which no longer needs or includes update-core!) -# -# If this step runs, it will require a full restart of MSYS2 before it -# can continue. -[ -x /usr/bin/update-core ] && /usr/bin/update-core - -set -e - -pacman --noconfirm -Syu # This step may require the terminal to be closed and restarted - -pacman --noconfirm -S --needed gettext-devel gcc git make ncurses-devel flex bison gperf vim \ - mingw-w64-i686-python-pip mingw-w64-i686-python-cryptography unzip winpty mingw-w64-i686-gcc - -# if IDF_PATH is set, install requirements now as well -if [ -n "$IDF_PATH" ]; then - python -m pip install -r "$IDF_PATH/requirements.txt" -fi - -# Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/ -TOOLCHAIN_ZIP=xtensa-esp32-elf-gcc8_4_0-esp-2021r2-win32.zip -echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..." -cd ~ -curl -LO --retry 10 https://dl.espressif.com/dl/${TOOLCHAIN_ZIP} -mkdir -p /opt -cd /opt -rm -rf /opt/xtensa-esp32-elf # for upgrades -unzip ~/${TOOLCHAIN_ZIP} -rm ~/${TOOLCHAIN_ZIP} - -cat > /etc/profile.d/esp32_toolchain.sh << EOF -# This file was created by ESP-IDF windows_install_prerequisites.sh -# and will be overwritten if that script is run again. -export PATH="/opt/xtensa-esp32-elf/bin:\$PATH" -EOF - -# clean up pacman package cache to save some disk space -pacman --noconfirm -Scc - -cat << EOF -************************************************ -MSYS2 environment is now ready to use ESP-IDF. - -1) Run 'source /etc/profile' to add the toolchain to -your path in this terminal. This command produces no output. -You only need to do this once, future terminals do this -automatically when opened. - -2) After ESP-IDF is set up (see setup guide), edit the file -`cygpath -w /etc/profile` -and add a line to set the variable IDF_PATH so it points to the -IDF directory, ie: - -export IDF_PATH=/c/path/to/esp-idf/directory - -************************************************ -EOF