diff --git a/bin/compile b/bin/compile index 6a67e2a..327fd72 100755 --- a/bin/compile +++ b/bin/compile @@ -25,9 +25,18 @@ for env_file in $BUILDPACK_VARIABLES ; do [ -f "$ENV_DIR/$env_file" ] && export "$(basename "$env_file")=$(cat "$ENV_DIR/$env_file" 2>/dev/null)" done +POETRY_VERSION="${POETRY_VERSION:-}" if [ -z "${POETRY_VERSION:-}" ] ; then - export POETRY_VERSION=1.5.1 - log "No Poetry version specified in POETRY_VERSION config var. Defaulting to $POETRY_VERSION." + if [ -f poetry.lock ]; then + POETRY_VERSION=$(head --lines=1 poetry.lock | grep --only-matching '\d\+\.\d\+\.\d\+') + fi + if [ -z "$POETRY_VERSION" ] ; then + export POETRY_VERSION=1.5.1 + log "No Poetry version specified in POETRY_VERSION config var. Defaulting to $POETRY_VERSION." + else + export POETRY_VERSION + log "Using Poetry version from poetry.lock: $POETRY_VERSION" + fi else log "Using Poetry version from POETRY_VERSION config var: $POETRY_VERSION" fi