Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Python 2 #36691

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
cclauss marked this conversation as resolved.
Show resolved Hide resolved
### 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)
cclauss marked this conversation as resolved.
Show resolved Hide resolved

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`.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -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" "$@"
]
Expand All @@ -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)
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/guides/maintaining-the-build-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down