From 4268fae04acc16b34fb302d63b01a85725ef2043 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 30 Dec 2020 15:09:52 +0100 Subject: [PATCH] build: remove support for Python 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/36691 Fixes: https://github.com/nodejs/node/issues/25789 Reviewed-By: Matteo Collina Reviewed-By: Michaël Zasso Reviewed-By: Jiawen Geng Reviewed-By: Zeyu Yang Reviewed-By: Rich Trott Reviewed-By: Ujjwal Sharma Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Richard Lau Reviewed-By: Beth Griggs Reviewed-By: Michael Dawson --- BUILDING.md | 33 +++++++++-------------- configure | 16 +++++------ configure.py | 2 +- doc/guides/maintaining-the-build-files.md | 2 +- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 2de444e9bd2a31..22d803c76a8518 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -19,7 +19,7 @@ file a new issue. * [OpenSSL asm support](#openssl-asm-support) * [Previous versions of this document](#previous-versions-of-this-document) * [Building Node.js on supported platforms](#building-nodejs-on-supported-platforms) - * [Note about Python 2 and Python 3](#note-about-python-2-and-python-3) + * [Note about Python](#note-about-python) * [Unix and macOS](#unix-and-macos) * [Unix prerequisites](#unix-prerequisites) * [macOS prerequisites](#macos-prerequisites) @@ -225,29 +225,23 @@ Consult previous versions of this document for older versions of Node.js: ## Building Node.js on supported platforms -### Note about Python 2 and Python 3 - -The Node.js project supports both Python 3 and Python 2 for building. -If both are installed Python 3 will be used. If only Python 2 is available -it will be used instead. When possible we recommend that you build and -test with Python 3. +### Note about Python +The Node.js project supports Python >= 3 for building and testing. ### Unix and macOS #### Unix prerequisites * `gcc` and `g++` >= 8.3 or newer, or * GNU Make 3.81 or newer -* Python (see note above) - * Python 2.7 - * Python 3.5, 3.6, 3.7, and 3.8 +* Python 3.6, 3.7, 3.8, and 3.9 (see note above) Installation via Linux package manager can be achieved with: -* Ubuntu, Debian: `sudo apt-get install python g++ make` -* Fedora: `sudo dnf install python gcc-c++ make` -* CentOS and RHEL: `sudo yum install python gcc-c++ make` -* OpenSUSE: `sudo zypper install python gcc-c++ make` +* Ubuntu, Debian: `sudo apt-get install python3 g++ make` +* Fedora: `sudo dnf install python3 gcc-c++ make` +* CentOS and RHEL: `sudo yum install python3 gcc-c++ make` +* OpenSUSE: `sudo zypper install python3 gcc-c++ make` * Arch Linux, Manjaro: `sudo pacman -S python gcc make` FreeBSD and OpenBSD users may also need to install `libexecinfo`. @@ -256,10 +250,8 @@ Python 3 users may also need to install `python3-distutils`. #### macOS prerequisites -* Xcode Command Line Tools >= 11 for macOS -* Python (see note above) - * Python 2.7 - * Python 3.5, 3.6, 3.7, and 3.8 +* Xcode Command Line Tools >= 10 for macOS +* Python 3.6, 3.7, 3.8, and 3.9 (see note above) macOS users can install the `Xcode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode @@ -568,7 +560,7 @@ to run it again before invoking `make -j4`. ##### Option 1: Manual install -* [Python 3.8](https://www.python.org/downloads/) +* [Python 3.9](https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7) * The "Desktop development with C++" workload from [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) or the "Visual C++ build tools" workload from the @@ -606,8 +598,7 @@ packages: * [Git for Windows](https://chocolatey.org/packages/git) with the `git` and Unix tools added to the `PATH` -* [Python 3.x](https://chocolatey.org/packages/python) and - [legacy Python](https://chocolatey.org/packages/python2) +* [Python 3.x](https://chocolatey.org/packages/python) * [Visual Studio 2019 Build Tools](https://chocolatey.org/packages/visualstudio2019buildtools) with [Visual C++ workload](https://chocolatey.org/packages/visualstudio2019-workload-vctools) * [NetWide Assembler](https://chocolatey.org/packages/nasm) diff --git a/configure b/configure index ca2cd8aa9e6358..dbe28730902466 100755 --- a/configure +++ b/configure @@ -1,17 +1,14 @@ #!/bin/sh -# Locate an acceptable python interpreter and then re-execute the script. +# Locate an acceptable Python interpreter and then re-execute the script. # Note that the mix of single and double quotes is intentional, # as is the fact that the ] goes on a new line. _=[ 'exec' '/bin/sh' '-c' ''' -test ${FORCE_PYTHON2} && exec python2 "$0" "$@" # workaround for gclient command -v python3.9 >/dev/null && exec python3.9 "$0" "$@" command -v python3.8 >/dev/null && exec python3.8 "$0" "$@" command -v python3.7 >/dev/null && exec python3.7 "$0" "$@" command -v python3.6 >/dev/null && exec python3.6 "$0" "$@" -command -v python3.5 >/dev/null && exec python3.5 "$0" "$@" command -v python3 >/dev/null && exec python3 "$0" "$@" -command -v python2.7 >/dev/null && exec python2.7 "$0" "$@" exec python "$0" "$@" ''' "$0" "$@" ] @@ -20,16 +17,15 @@ del _ import sys from distutils.spawn import find_executable -print('Node.js configure: Found Python {0}.{1}.{2}...'.format(*sys.version_info)) -acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7)) +print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info)) +acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6)) if sys.version_info[:2] in acceptable_pythons: import configure else: - python_cmds = ['python{0}.{1}'.format(*vers) for vers in acceptable_pythons] - sys.stderr.write('Please use {0}.\n'.format(' or '.join(python_cmds))) + python_cmds = ['python{}.{}'.format(*vers) for vers in acceptable_pythons] + sys.stderr.write('Please use {}.\n'.format(' or '.join(python_cmds))) for python_cmd in python_cmds: python_cmd_path = find_executable(python_cmd) if python_cmd_path and 'pyenv/shims' not in python_cmd_path: - sys.stderr.write('\t{0} {1}\n'.format(python_cmd_path, - ' '.join(sys.argv[:1]))) + sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1]))) sys.exit(1) diff --git a/configure.py b/configure.py index 65fcbc8f28267c..6798b4a445c387 100755 --- a/configure.py +++ b/configure.py @@ -1827,7 +1827,7 @@ def make_bin_override(): if sys.platform == 'win32': raise Exception('make_bin_override should not be called on win32.') # If the system python is not the python we are running (which should be - # python 2), then create a directory with a symlink called `python` to our + # python 3), then create a directory with a symlink called `python` to our # sys.executable. This directory will be prefixed to the PATH, so that # other tools that shell out to `python` will use the appropriate python diff --git a/doc/guides/maintaining-the-build-files.md b/doc/guides/maintaining-the-build-files.md index 548441dc0126ca..67c86281c63ed4 100644 --- a/doc/guides/maintaining-the-build-files.md +++ b/doc/guides/maintaining-the-build-files.md @@ -8,7 +8,7 @@ On how to build the Node.js core, see [Building Node.js](../../BUILDING.md). There are three main build files that may be directly run when building Node.js: -* `configure`: A Python 2 script that detects system capabilities and runs +* `configure`: A Python script that detects system capabilities and runs [GYP][]. It generates `config.gypi` which includes parameters used by GYP to create platform-dependent build files. Its output is usually in one of these formats: Makefile, MSbuild, ninja, or XCode project files (the main