Commit 9b7ce281 authored by vieira's avatar vieira Committed by Brian May

Use versions of python3 greater than 3.5 when available (e.g. 3.6)

Some Linux distros, like Alpine, Arch, etc and some BSDs, like FreeBSD, are
now shipping with python3.6 as the default python3. Both the client and the
server are failing to run in this distros, because we are specifically looking
for python3.5.

These changes make the run shell script use python3 if the version is greater
than 3.5, otherwise falling back as usual.

On the server any version of python3 will do, use it before falling back to
python, as the server code can run with any version of python3.
parent 7726dea2
#!/bin/sh #!/usr/bin/env sh
source_dir="$(dirname $0)" set -e
(cd "$source_dir" && "$source_dir/setup.py" --version > /dev/null) export PYTHONPATH="$(dirname $0):$PYTHONPATH"
export PYTHONPATH="$source_dir:$PYTHONPATH"
if python3.5 -V >/dev/null 2>&1; then python_best_version() {
exec python3.5 -m "sshuttle" "$@" if [ -x "$(command -v python3)" ]; then
elif python2.7 -V >/dev/null 2>&1; then if python3 -c "import sys; sys.exit(not sys.version_info > (3, 5))"; then
exec python2.7 -m "sshuttle" "$@" exec python3 "$@"
else fi
exec python -m "sshuttle" "$@" elif [ -x "$(command -v python2.7)" ]; then
fi exec python2.7 "$@"
else
exec python "$@"
fi
}
python_best_version -m "sshuttle" "$@"
...@@ -116,7 +116,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options): ...@@ -116,7 +116,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
if python: if python:
pycmd = "'%s' -c '%s'" % (python, pyscript) pycmd = "'%s' -c '%s'" % (python, pyscript)
else: else:
pycmd = ("P=python3.5; $P -V 2>/dev/null || P=python; " pycmd = ("P=python3; $P -V 2>/dev/null || P=python; "
"exec \"$P\" -c %s") % quote(pyscript) "exec \"$P\" -c %s") % quote(pyscript)
pycmd = ("exec /bin/sh -c %s" % quote(pycmd)) pycmd = ("exec /bin/sh -c %s" % quote(pycmd))
argv = (sshl + argv = (sshl +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment