Skip to content

Commit e82f1e4

Browse files
committed
add Python version operators
1 parent f7e5930 commit e82f1e4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

bin/utils

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,30 @@ measure-size() {
5858
echo "$(du -s .heroku/python 2>/dev/null || echo 0) | awk '{print $1}')"
5959
}
6060

61+
# Python version operator >
62+
version_gt() {
63+
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
64+
}
65+
66+
# Python verison operator >=
67+
version_gte() {
68+
if [ "$1" == "$2" ]; then
69+
return 0
70+
fi
71+
72+
version_gt "$1" "$2"
73+
}
74+
75+
# Check if Python 2
76+
python2_check() {
77+
VERSION="$1"
78+
79+
version_gte "$VERSION" "python-2.7.0" && version_gt "python-3.0.0" "$VERSION"
80+
}
81+
82+
# Check if Python 3
83+
python3_check() {
84+
VERSION="$1"
85+
86+
version_gte "$VERSION" "python-3.0.0" && version_gt "python-4.0.0" "$VERSION"
87+
}

0 commit comments

Comments
 (0)