Skip to content

Commit 754aa38

Browse files
richardlautargos
authored andcommitted
build: remove dependency on distutils.spawn
Debian based packages of Python 3 do not include `distutils.spawn` and require an additional apt package to be installed (`python3-distutils`). Replace use of `distutils.spawn` with `shutil.which`, available in all versions of Python currently allowed by our configure scripts. For the `configure` script only, fall back to `distutils.spawn` to allow friendlier error messages when run on older unsupported versions of Python (e.g. 2.7). `configure.py` also uses `distutils.version` -- this appears to be available in Debian packaged Python 3 without installing `python3-distutils` so has been left as-is. PR-URL: #38600 Refs: #30189 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent bac9ba4 commit 754aa38

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

BUILDING.md

-7
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ Installation via Linux package manager can be achieved with:
250250

251251
FreeBSD and OpenBSD users may also need to install `libexecinfo`.
252252

253-
Python 3 users may also need to install `python3-distutils`.
254-
255253
#### macOS prerequisites
256254

257255
* Xcode Command Line Tools >= 10 for macOS
@@ -277,11 +275,6 @@ $ ./configure
277275
$ make -j4
278276
```
279277

280-
If you run into a `No module named 'distutils.spawn'` error when executing
281-
`./configure`, please try `python3 -m pip install --upgrade setuptools` or
282-
`sudo apt install python3-distutils -y`.
283-
For more information, see <https://github.com./nodejs/node/issues/30189>.
284-
285278
The `-j4` option will cause `make` to run 4 simultaneous compilation jobs which
286279
may reduce build time. For more information, see the
287280
[GNU Make Documentation](https://www.gnu.org/software/make/manual/html_node/Parallel.html).

configure

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ exec python "$0" "$@"
1818
del _
1919

2020
import sys
21-
from distutils.spawn import find_executable
21+
try:
22+
from shutil import which
23+
except ImportError:
24+
from distutils.spawn import find_executable as which
2225

2326
print('Node.js configure: Found Python {0}.{1}.{2}...'.format(*sys.version_info))
2427
acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7))
@@ -28,7 +31,7 @@ else:
2831
python_cmds = ['python{0}.{1}'.format(*vers) for vers in acceptable_pythons]
2932
sys.stderr.write('Please use {0}.\n'.format(' or '.join(python_cmds)))
3033
for python_cmd in python_cmds:
31-
python_cmd_path = find_executable(python_cmd)
34+
python_cmd_path = which(python_cmd)
3235
if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
3336
sys.stderr.write('\t{0} {1}\n'.format(python_cmd_path,
3437
' '.join(sys.argv[:1])))

configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import bz2
1515
import io
1616

17-
from distutils.spawn import find_executable as which
17+
from shutil import which
1818
from distutils.version import StrictVersion
1919

2020
# If not run from node/, cd to node/.

0 commit comments

Comments
 (0)