Skip to content

Commit 66dd898

Browse files
bnoordhuisMylesBorins
authored andcommitted
build: better support for python3 systems
Improve support for systems where `python` is actually `python3`. Not all systems have a `python2` binary, so simply updating the shebang won't work. What we can do is apply some cleverness: start life as a shell script, locate the python binary, then re-execute the script but this time as python code. Special care is taken to ensure that spaces in arguments are passed on verbatim. PR-URL: #14737 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent 1e231ba commit 66dd898

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

configure

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
#!/usr/bin/env python
1+
#!/bin/sh
2+
3+
# Locate python2 interpreter and re-execute the script. Note that the
4+
# mix of single and double quotes is intentional, as is the fact that
5+
# the ] goes on a new line.
6+
_=[ 'exec' '/bin/sh' '-c' '''
7+
which python2.7 >/dev/null && exec python2.7 "$0" "$@"
8+
which python2 >/dev/null && exec python2 "$0" "$@"
9+
exec python "$0" "$@"
10+
''' "$0" "$@"
11+
]
12+
del _
213

314
import sys
415
if sys.version_info[0] != 2 or sys.version_info[1] not in (6, 7):

0 commit comments

Comments
 (0)