@@ -36,23 +36,39 @@ if [ -f ~/.bashrc ]; then
3636fi
3737'
3838
39- python_command ='
39+ PYTHON_VERSION_COMMAND ='
4040import sys
41- if (3, 5, 0) < sys.version_info < (3, 9 , 0):
41+ if (3, 5, 0) < sys.version_info < (3, 11 , 0):
4242 sys.exit(0)
43- elif (2, 7, 0 ) < sys.version_info < (3,0):
43+ elif (2, 7, 8 ) < sys.version_info < (3,0):
4444 sys.exit(0)
4545else:
4646 sys.exit(-1)'
4747
48+ # Prefer Python 3 versions over Python 2
49+ PYTHON_VERSION_ARRAY=(
50+ " /usr/bin/python3"
51+ " python3"
52+ " python3.10"
53+ " python3.9"
54+ " python3.8"
55+ " python3.7"
56+ " python3.6"
57+ " python3.5"
58+ " python"
59+ " python2.7"
60+ " python27"
61+ " python2"
62+ )
63+
4864bashhub_config=~ /.bashhub/config
4965backup_config=~ /.bashhub.config.backup
5066zshprofile=~ /.zshrc
5167fish_config=" ${XDG_CONFIG_HOME:- ~/ .config} /fish/config.fish"
5268
5369# Optional parameter to specify a github branch
5470# to pull from.
55- github_branch=${1:- ' 2.1.3 ' }
71+ github_branch=${1:- ' 2.2.0 ' }
5672
5773install_bashhub () {
5874 check_dependencies
@@ -61,12 +77,10 @@ install_bashhub() {
6177}
6278
6379get_and_check_python_version () {
64- # Prefer Python 3 versions over python 2
65- python_version_array=( " python3.8" " python3.7" " python3.6" " python3.5" " python3" " python" " python2.7" " python27" " python2" )
6680
67- for python_version in " ${python_version_array [@]} " ; do
81+ for python_version in " ${PYTHON_VERSION_ARRAY [@]} " ; do
6882 if type " $python_version " & > /dev/null; then
69- if " $python_version " -c " $python_command " ; then
83+ if " $python_version " -c " $PYTHON_VERSION_COMMAND " ; then
7084 echo " $python_version "
7185 return 0
7286 fi
@@ -76,40 +90,31 @@ get_and_check_python_version() {
7690 return 1
7791}
7892
93+ # Boostrap virtualenv via zipapp
94+ # Details https://virtualenv.pypa.io/en/latest/installation.html#via-zipapp
7995download_and_install_env () {
80- # Select current version of virtualenv:
81- VERSION=16.7.10
82- # Name your first "bootstrap" environment:
83- INITIAL_ENV=" env"
84- # Options for your first environment:
85- ENV_OPTS=" --distribute"
86-
87- # Only supporting 2.7 right now.
88- python_command=$( get_and_check_python_version)
96+ local python_command=$( get_and_check_python_version)
8997 if [[ -z " $python_command " ]]; then
90- die " \n Sorry you need to have python 3.5-3.8 or 2.7 installed. Please install it and rerun this script." 1
98+ die " \n Sorry you need to have python 3.5-3.10 or 2.7.9+ installed. Please install it and rerun this script." 1
9199 fi
92100
93101 # Set to whatever python interpreter you want for your first environment
94102 PYTHON=$( which $python_command )
95- URL_BASE=https://pypi.python.org/packages/source/v/virtualenv
96-
97- # --- Real work starts here ---
98- curl -OL $URL_BASE /virtualenv-$VERSION .tar.gz
99- tar xzf virtualenv-$VERSION .tar.gz
100-
101- # Create the first "bootstrap" environment.
102103 echo " Using Python path $PYTHON "
103- $PYTHON virtualenv-$VERSION /virtualenv.py " $ENV_OPTS " " $INITIAL_ENV "
104104
105- # Remove our virtual env setup files we don't need anymore
106- rm -rf virtualenv-$VERSION
107- rm virtualenv-$VERSION .tar.gz
105+ VERSION=20.10.0
106+ VERSION_URL=" https://github.com/pypa/get-virtualenv/raw/$VERSION /public/virtualenv.pyz"
107+ # Alternatively use latest url for most recent that should be 2.7-3.9+
108+ LATEST_URL=" https://bootstrap.pypa.io/virtualenv/2.7/virtualenv.pyz"
109+ curl -OL $VERSION_URL
110+ # Create the first "bootstrap" environment.
111+ $PYTHON virtualenv.pyz -q env
112+ rm virtualenv.pyz
108113}
109114
110115check_dependencies () {
111116 if [ -z " $( get_and_check_python_version) " ]; then
112- die " \n Sorry can't seem to find a version of python 3.5-3.8 or 2.7 installed" 1
117+ die " \n Sorry can't seem to find a version of python 3.5-3.10 or 2.7.9+ installed" 1
113118 fi
114119
115120 if [ -z " $( detect_shell_type) " ]; then
0 commit comments