pipenv-python-version 728 Bytes
Newer Older
1 2
# Detect Python-version with Pipenv.

Kenneth Reitz's avatar
v100  
Kenneth Reitz committed
3
if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
4 5

    if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
Kenneth Reitz's avatar
Kenneth Reitz committed
6 7
        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
8
        fi
Kenneth Reitz's avatar
Kenneth Reitz committed
9 10 11 12
        if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
            set +e
            PYTHON=$(cat $BUILD_DIR/Pipfile.lock | jq '._meta.requires.python_version' -r)
            set -e
Kenneth Reitz's avatar
Kenneth Reitz committed
13

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