Merge pull request #139 from jdxcode/master
added major/minor shorthands
This commit is contained in:
commit
345f99c439
2 changed files with 51 additions and 3 deletions
30
bin/install
30
bin/install
|
@ -6,8 +6,12 @@ source "$(dirname "$0")/utils.sh"
|
||||||
|
|
||||||
install_python() {
|
install_python() {
|
||||||
local install_type=$1
|
local install_type=$1
|
||||||
local version=$2
|
local version
|
||||||
local install_path=$3
|
local symlink_path=$3
|
||||||
|
local install_path
|
||||||
|
|
||||||
|
version="$(resolve_partial_version "$2")"
|
||||||
|
install_path="$(dirname "$symlink_path")/$version"
|
||||||
|
|
||||||
if [ "$install_type" != "version" ]; then
|
if [ "$install_type" != "version" ]; then
|
||||||
echoerr "Cannot install specific ref from source, sorry."
|
echoerr "Cannot install specific ref from source, sorry."
|
||||||
|
@ -28,6 +32,13 @@ install_python() {
|
||||||
echo "python-build $version $install_path"
|
echo "python-build $version $install_path"
|
||||||
$(python_build_path) "$version" "$install_path"
|
$(python_build_path) "$version" "$install_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$install_path" != "$symlink_path" ]; then
|
||||||
|
# add a symlink for an alias like:
|
||||||
|
# ~/.asdf/installs/python/3 -> ~/.asdf/installs/python/3.1.2
|
||||||
|
rmdir "$symlink_path" # asdf creates this empty directory we don't want
|
||||||
|
ln -sfv "$install_path" "$symlink_path"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_default_python_packages() {
|
install_default_python_packages() {
|
||||||
|
@ -39,6 +50,21 @@ install_default_python_packages() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fetch_all_versions() {
|
||||||
|
$(python_build_path) --definitions | grep -E '^\d+\.\d+\.\d+$' | sort -rV
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_partial_version() {
|
||||||
|
local version=$1
|
||||||
|
if [[ "$version" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
|
||||||
|
# maps a version like "3.0" or "3" to "3.1.2"
|
||||||
|
fetch_all_versions | grep -e "^$version\." | head -n1
|
||||||
|
else
|
||||||
|
echo "$version"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
ensure_python_build_installed
|
ensure_python_build_installed
|
||||||
install_python "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
|
install_python "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
|
||||||
install_default_python_packages
|
install_default_python_packages
|
||||||
|
|
24
bin/list-all
24
bin/list-all
|
@ -4,7 +4,29 @@ source "$(dirname "$0")/utils.sh"
|
||||||
|
|
||||||
list_all() {
|
list_all() {
|
||||||
install_or_update_python_build
|
install_or_update_python_build
|
||||||
$(python_build_path) --definitions | tr '\n' ' '
|
echo $(
|
||||||
|
$(python_build_path) --definitions
|
||||||
|
echo 2
|
||||||
|
echo 2.1
|
||||||
|
echo 2.2
|
||||||
|
echo 2.3
|
||||||
|
echo 2.4
|
||||||
|
echo 2.5
|
||||||
|
echo 2.6
|
||||||
|
echo 2.7
|
||||||
|
echo 3
|
||||||
|
echo 3.0
|
||||||
|
echo 3.1
|
||||||
|
echo 3.2
|
||||||
|
echo 3.3
|
||||||
|
echo 3.4
|
||||||
|
echo 3.5
|
||||||
|
echo 3.6
|
||||||
|
echo 3.7
|
||||||
|
echo 3.8
|
||||||
|
echo 3.9
|
||||||
|
echo 3.10
|
||||||
|
) | tr '\n' ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
list_all
|
list_all
|
||||||
|
|
Loading…
Reference in a new issue