File: show_python_versions

package info (click to toggle)
python-mitogen 0.3.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,708 kB
  • sloc: python: 24,457; sh: 198; makefile: 74; perl: 19; ansic: 18
file content (33 lines) | stat: -rwxr-xr-x 970 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail

INDENT="    "
POSSIBLE_PYTHONS=(
    python
    python2
    python3
    /usr/bin/python
    /usr/bin/python2
    /usr/bin/python3
    # GitHub macOS 12 images: python2.7 is installed, but not on $PATH
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
)

for p in "${POSSIBLE_PYTHONS[@]}"; do
    echo "$p"
    if [[ ${p:0:1} == "/" && -e $p ]]; then
        :
    elif type "$p" > /dev/null 2>&1; then
        type "$p" 2>&1 | sed -e "s/^/${INDENT}type: /"
    else
        echo "${INDENT}Not present"
        echo
        continue
    fi

    $p -c "import sys;          print('${INDENT}version:        %d.%d.%d' % sys.version_info[:3])"
    # macOS builders lack a realpath command
    $p -c "import os.path;      print('${INDENT}realpath:       %s' % os.path.realpath('$(type -p "$p")'))"
    $p -c "import sys;          print('${INDENT}sys.executable: %s' % sys.executable)"
    echo
done