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

Choose an appropriate python version for x.py at runtime #80585

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 15 additions & 1 deletion x.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/usr/bin/env python
# The beginning of this script is both valid shell and valid python, such that
# the script starts with the shell and is reexecuted with the right python.
# This works because shells only execute a line at a time.
# Thanks to `./mach` from servo for the idea!
''':' && {
exists() { command -v "$1" >/dev/null 2>&1; }
if exists python3; then
exec python3 "$0" "$@"
elif exists python; then
exec python "$0" "$@"
else
exec python2 "$0" "$@"
fi
}
'''

# This file is only a "symlink" to bootstrap.py, all logic should go there.

Expand Down