pipenv-python-version 744 Bytes
Newer Older
Kenneth Reitz's avatar
Kenneth Reitz committed
1 2
#!/usr/bin/env bash

3 4
# Detect Python-version with Pipenv.

Kenneth Reitz's avatar
Kenneth Reitz committed
5
if [[ -f $BUILD_DIR/Pipfile ]]; then
6 7

    if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
Kenneth Reitz's avatar
Kenneth Reitz committed
8 9
        if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then
            puts-warn "No 'pipfile.lock' found! We recommend you commit this into your repository."
Kenneth Reitz's avatar
Kenneth Reitz committed
10
        fi
Kenneth Reitz's avatar
Kenneth Reitz committed
11 12
        if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
            set +e
Kenneth Reitz's avatar
Kenneth Reitz committed
13
            PYTHON=$(jq -r '._meta.requires.python_version' "$BUILD_DIR/Pipfile.lock")
Kenneth Reitz's avatar
Kenneth Reitz committed
14
            set -e
Kenneth Reitz's avatar
Kenneth Reitz committed
15

Kenneth Reitz's avatar
Kenneth Reitz committed
16
            if [ "$PYTHON" = 2.7 ]; then
Kenneth Reitz's avatar
Kenneth Reitz committed
17
                echo "python-2.7.13" > "$BUILD_DIR/runtime.txt"
Kenneth Reitz's avatar
Kenneth Reitz committed
18 19
            fi
            if [ "$PYTHON" = 3.6 ]; then
Kenneth Reitz's avatar
Kenneth Reitz committed
20
                echo "python-3.6.2" > "$BUILD_DIR/runtime.txt"
Kenneth Reitz's avatar
Kenneth Reitz committed
21
            fi
22 23 24 25
        fi
    fi
fi