mirror of
https://github.com/frej/fast-export.git
synced 2026-01-14 18:22:05 +01:00
Try to do the right thing on non PEP394 compliant systems
PEP 394 [1] tells us that on systems with both a python 2 and 3 installed, the python 2 interpreter should be installed as python2. Unfortunately not all distributions adheres to PEP 394 (I'm looking at you, Windows) so to handle that we first try to find a 'python2', then fall back on plain 'python'. In order to not silently pick a python 3 by mistake, we check sys.version_info using the the interpreter we found. [1] https://www.python.org/dev/peps/pep-0394/
This commit is contained in:
@@ -26,7 +26,29 @@ SFX_MARKS="marks"
|
||||
SFX_HEADS="heads"
|
||||
SFX_STATE="state"
|
||||
GFI_OPTS=""
|
||||
PYTHON=${PYTHON:-python2}
|
||||
|
||||
if [ -z "${PYTHON}" ]; then
|
||||
# $PYTHON is not set, so we try to find a working python 2.7 to
|
||||
# use. PEP 394 tells us to use 'python2', otherwise try plain
|
||||
# 'python'.
|
||||
if command -v python2 > /dev/null; then
|
||||
PYTHON="python2"
|
||||
elif command -v python > /dev/null; then
|
||||
PYTHON="python"
|
||||
else
|
||||
echo "Could not find any python interpreter, please use the 'PYTHON'" \
|
||||
"environment variable to specify the interpreter to use."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check that the python specified by the user or autodetected above is
|
||||
# >= 2.7 and < 3.
|
||||
if ! ${PYTHON} -c 'import sys; v=sys.version_info; exit(0 if v.major == 2 and v.minor >= 7 else 1)' > /dev/null 2>&1 ; then
|
||||
echo "${PYTHON} is not a working python 2.7 interpreter, please use the" \
|
||||
"'PYTHON' environment variable to specify the interpreter to use."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USAGE="[--quiet] [-r <repo>] [--force] [-m <max>] [-s] [--hgtags] [-A <file>] [-B <file>] [-T <file>] [-M <name>] [-o <name>] [--hg-hash] [-e <encoding>]"
|
||||
LONG_USAGE="Import hg repository <repo> up to either tip or <max>
|
||||
|
||||
Reference in New Issue
Block a user