Skip to content

Commit dfb30e3

Browse files
committed
make list-all script non-dependent on python to avoid library/versioning issues
1 parent 06a3181 commit dfb30e3

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

bin/check-python

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ PYTHON_MINIMUM_MINOR=4
1010
PYTHON3_REF=$(which python3 | grep "/python3")
1111
PYTHON_REF=$(which python | grep "/python")
1212

13-
error_msg(){
14-
echo "NoPython"
13+
error_msg() {
14+
echo "NoPython"
1515
}
1616

17-
python_ref(){
18-
local my_ref=$1
19-
echo $($my_ref -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major); print(minor);')
17+
python_ref() {
18+
local my_ref=$1
19+
echo $($my_ref -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major); print(minor);')
2020
}
2121

2222
# Print success_msg/error_msg according to the provided minimum required versions
23-
check_version(){
24-
local major=$1
25-
local minor=$2
26-
local python_ref=$3
27-
[[ $major -ge $PYTHON_MINIMUM_MAJOR && $minor -ge $PYTHON_MINIMUM_MINOR ]] && echo $python_ref || error_msg
23+
check_version() {
24+
local major=$1
25+
local minor=$2
26+
local python_ref=$3
27+
[[ $major -ge $PYTHON_MINIMUM_MAJOR && $minor -ge $PYTHON_MINIMUM_MINOR ]] && echo $python_ref || error_msg
2828
}
2929

3030
# Logic
3131
if [[ ! -z $PYTHON3_REF ]]; then
32-
version=($(python_ref python3))
33-
check_version ${version[0]} ${version[1]} $PYTHON3_REF
32+
version=($(python_ref python3))
33+
check_version ${version[0]} ${version[1]} $PYTHON3_REF
3434
elif [[ ! -z $PYTHON_REF ]]; then
35-
# Didn't find python3, let's try python
36-
version=($(python_ref python))
37-
check_version ${version[0]} ${version[1]} $PYTHON_REF
35+
# Didn't find python3, let's try python
36+
version=($(python_ref python))
37+
check_version ${version[0]} ${version[1]} $PYTHON_REF
3838
else
39-
# Python is not installed at all
40-
error_msg
39+
# Python is not installed at all
40+
error_msg
4141
fi

bin/install

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66

77
PYTHON_REF=$(source ${__dir}/check-python)
88
if [[ "$PYTHON_REF" == "NoPython" ]]; then
9-
echo "Python3.4+ is not installed."
10-
exit
9+
echo "Python3.4+ is not installed."
10+
exit
1111
fi
1212

1313
# create and activate virtual environment
@@ -24,12 +24,12 @@ mkdir $ASDF_INSTALL_PATH/asdf_bin
2424
declare -a executables=("pipenv" "pipenv-resolver")
2525
for filename in "${executables[@]}"
2626
do
27-
cat <<EOT >> $ASDF_INSTALL_PATH/asdf_bin/$filename
27+
cat <<EOT >> $ASDF_INSTALL_PATH/asdf_bin/$filename
2828
#!/usr/bin/env bash
2929
3030
source $ASDF_INSTALL_PATH/bin/activate
3131
PIPENV_IGNORE_VIRTUALENVS=1 $filename "\$@"
3232
EOT
3333

34-
chmod a+x $ASDF_INSTALL_PATH/asdf_bin/$filename
34+
chmod a+x $ASDF_INSTALL_PATH/asdf_bin/$filename
3535
done

bin/list-all

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ set -eu
55
cmd="curl --silent --location"
66
releases_path="https://pypi.org/pypi/pipenv/json"
77

8-
versions=$(eval "$cmd $releases_path" | exec python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(' '.join(sorted(releases, key=pkg_resources.parse_version)))")
8+
versions=$($cmd "$releases_path" |
9+
sed -E 's/.*"releases":\{(.*?)\},"urls".*/\1/' |
10+
grep -oE '"[^"]+":\[' |
11+
sed -E 's/^"([^"]+)":\[/\1/' |
12+
sort -V
13+
)
914

1015
echo "$versions"

0 commit comments

Comments
 (0)