pipenv-python-version 558 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 6

    if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
        if [[ ! -f Pipfile.lock ]]; then
Kenneth Reitz's avatar
v100  
Kenneth Reitz committed
7
            pipenv lock 2> /dev/null
Kenneth Reitz's avatar
Kenneth Reitz committed
8 9
        fi

Kenneth Reitz's avatar
v100  
Kenneth Reitz committed
10 11 12
        set +e
        PYTHON=$(cat $BUILD_DIR/Pipfile.lock | jq '._meta.requires.python_version' -r)
        set -e
13

Kenneth Reitz's avatar
v100  
Kenneth Reitz committed
14 15 16 17 18
        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
19 20 21 22
        fi
    fi
fi