Skip to content

Commit 4268fae

Browse files
cclaussrichardlau
authored andcommitted
build: remove support for Python 2
PR-URL: #36691 Fixes: #25789 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 6d04cc6 commit 4268fae

File tree

4 files changed

+20
-33
lines changed

4 files changed

+20
-33
lines changed

Diff for: BUILDING.md

+12-21
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ file a new issue.
1919
* [OpenSSL asm support](#openssl-asm-support)
2020
* [Previous versions of this document](#previous-versions-of-this-document)
2121
* [Building Node.js on supported platforms](#building-nodejs-on-supported-platforms)
22-
* [Note about Python 2 and Python 3](#note-about-python-2-and-python-3)
22+
* [Note about Python](#note-about-python)
2323
* [Unix and macOS](#unix-and-macos)
2424
* [Unix prerequisites](#unix-prerequisites)
2525
* [macOS prerequisites](#macos-prerequisites)
@@ -225,29 +225,23 @@ Consult previous versions of this document for older versions of Node.js:
225225

226226
## Building Node.js on supported platforms
227227

228-
### Note about Python 2 and Python 3
229-
230-
The Node.js project supports both Python 3 and Python 2 for building.
231-
If both are installed Python 3 will be used. If only Python 2 is available
232-
it will be used instead. When possible we recommend that you build and
233-
test with Python 3.
228+
### Note about Python
234229

230+
The Node.js project supports Python >= 3 for building and testing.
235231
### Unix and macOS
236232

237233
#### Unix prerequisites
238234

239235
* `gcc` and `g++` >= 8.3 or newer, or
240236
* GNU Make 3.81 or newer
241-
* Python (see note above)
242-
* Python 2.7
243-
* Python 3.5, 3.6, 3.7, and 3.8
237+
* Python 3.6, 3.7, 3.8, and 3.9 (see note above)
244238

245239
Installation via Linux package manager can be achieved with:
246240

247-
* Ubuntu, Debian: `sudo apt-get install python g++ make`
248-
* Fedora: `sudo dnf install python gcc-c++ make`
249-
* CentOS and RHEL: `sudo yum install python gcc-c++ make`
250-
* OpenSUSE: `sudo zypper install python gcc-c++ make`
241+
* Ubuntu, Debian: `sudo apt-get install python3 g++ make`
242+
* Fedora: `sudo dnf install python3 gcc-c++ make`
243+
* CentOS and RHEL: `sudo yum install python3 gcc-c++ make`
244+
* OpenSUSE: `sudo zypper install python3 gcc-c++ make`
251245
* Arch Linux, Manjaro: `sudo pacman -S python gcc make`
252246

253247
FreeBSD and OpenBSD users may also need to install `libexecinfo`.
@@ -256,10 +250,8 @@ Python 3 users may also need to install `python3-distutils`.
256250

257251
#### macOS prerequisites
258252

259-
* Xcode Command Line Tools >= 11 for macOS
260-
* Python (see note above)
261-
* Python 2.7
262-
* Python 3.5, 3.6, 3.7, and 3.8
253+
* Xcode Command Line Tools >= 10 for macOS
254+
* Python 3.6, 3.7, 3.8, and 3.9 (see note above)
263255

264256
macOS users can install the `Xcode Command Line Tools` by running
265257
`xcode-select --install`. Alternatively, if you already have the full Xcode
@@ -568,7 +560,7 @@ to run it again before invoking `make -j4`.
568560

569561
##### Option 1: Manual install
570562

571-
* [Python 3.8](https://www.python.org/downloads/)
563+
* [Python 3.9](https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7)
572564
* The "Desktop development with C++" workload from
573565
[Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) or
574566
the "Visual C++ build tools" workload from the
@@ -606,8 +598,7 @@ packages:
606598

607599
* [Git for Windows](https://chocolatey.org/packages/git) with the `git` and
608600
Unix tools added to the `PATH`
609-
* [Python 3.x](https://chocolatey.org/packages/python) and
610-
[legacy Python](https://chocolatey.org/packages/python2)
601+
* [Python 3.x](https://chocolatey.org/packages/python)
611602
* [Visual Studio 2019 Build Tools](https://chocolatey.org/packages/visualstudio2019buildtools)
612603
with [Visual C++ workload](https://chocolatey.org/packages/visualstudio2019-workload-vctools)
613604
* [NetWide Assembler](https://chocolatey.org/packages/nasm)

Diff for: configure

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#!/bin/sh
22

3-
# Locate an acceptable python interpreter and then re-execute the script.
3+
# Locate an acceptable Python interpreter and then re-execute the script.
44
# Note that the mix of single and double quotes is intentional,
55
# as is the fact that the ] goes on a new line.
66
_=[ 'exec' '/bin/sh' '-c' '''
7-
test ${FORCE_PYTHON2} && exec python2 "$0" "$@" # workaround for gclient
87
command -v python3.9 >/dev/null && exec python3.9 "$0" "$@"
98
command -v python3.8 >/dev/null && exec python3.8 "$0" "$@"
109
command -v python3.7 >/dev/null && exec python3.7 "$0" "$@"
1110
command -v python3.6 >/dev/null && exec python3.6 "$0" "$@"
12-
command -v python3.5 >/dev/null && exec python3.5 "$0" "$@"
1311
command -v python3 >/dev/null && exec python3 "$0" "$@"
14-
command -v python2.7 >/dev/null && exec python2.7 "$0" "$@"
1512
exec python "$0" "$@"
1613
''' "$0" "$@"
1714
]
@@ -20,16 +17,15 @@ del _
2017
import sys
2118
from distutils.spawn import find_executable
2219

23-
print('Node.js configure: Found Python {0}.{1}.{2}...'.format(*sys.version_info))
24-
acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7))
20+
print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info))
21+
acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6))
2522
if sys.version_info[:2] in acceptable_pythons:
2623
import configure
2724
else:
28-
python_cmds = ['python{0}.{1}'.format(*vers) for vers in acceptable_pythons]
29-
sys.stderr.write('Please use {0}.\n'.format(' or '.join(python_cmds)))
25+
python_cmds = ['python{}.{}'.format(*vers) for vers in acceptable_pythons]
26+
sys.stderr.write('Please use {}.\n'.format(' or '.join(python_cmds)))
3027
for python_cmd in python_cmds:
3128
python_cmd_path = find_executable(python_cmd)
3229
if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
33-
sys.stderr.write('\t{0} {1}\n'.format(python_cmd_path,
34-
' '.join(sys.argv[:1])))
30+
sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1])))
3531
sys.exit(1)

Diff for: configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ def make_bin_override():
18271827
if sys.platform == 'win32':
18281828
raise Exception('make_bin_override should not be called on win32.')
18291829
# If the system python is not the python we are running (which should be
1830-
# python 2), then create a directory with a symlink called `python` to our
1830+
# python 3), then create a directory with a symlink called `python` to our
18311831
# sys.executable. This directory will be prefixed to the PATH, so that
18321832
# other tools that shell out to `python` will use the appropriate python
18331833

Diff for: doc/guides/maintaining-the-build-files.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ On how to build the Node.js core, see [Building Node.js](../../BUILDING.md).
88

99
There are three main build files that may be directly run when building Node.js:
1010

11-
* `configure`: A Python 2 script that detects system capabilities and runs
11+
* `configure`: A Python script that detects system capabilities and runs
1212
[GYP][]. It generates `config.gypi` which includes parameters used by GYP to
1313
create platform-dependent build files. Its output is usually in one of these
1414
formats: Makefile, MSbuild, ninja, or XCode project files (the main

0 commit comments

Comments
 (0)