-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathinstall
executable file
·45 lines (35 loc) · 1.3 KB
/
install
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
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR
cleanup() {
trap - SIGINT SIGTERM ERR
rm -rf "$ASDF_INSTALL_PATH"
echo
echo "Cleanup: Something went wrong!"
echo
echo "$(caller): ${BASH_COMMAND}"
}
semver_ge() {
printf '%s\n%s\n' "$2" "$1" | sort --check=quiet --version-sort
}
install_poetry() {
local install_type=$1
local version=$2
local install_path=$3
# Ensure the installer will work even if the user has the
# PIP_REQUIRE_VIRTUALENV variable set. Can be removed after this issue is
# resolved: https://github.com/python-poetry/poetry/issues/4089
unset PIP_REQUIRE_VIRTUALENV
if [ "$install_type" != "version" ]; then
fail "asdf-poetry supports release installs only"
fi
semver_ge "$ASDF_INSTALL_VERSION" 1.2.0 && vercomp="ge" || vercomp="lt"
if [ $vercomp == "ge" ]; then
install_url="https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py"
curl -sSL "$install_url" | POETRY_HOME=$install_path python3 - --version "$version"
else
install_url="https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py"
curl -sSL "$install_url" | POETRY_HOME=$install_path python3 - --version "$version" --no-modify-path
fi
}
install_poetry "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"