diff --git a/bashhub/version.py b/bashhub/version.py index 5cbe71d..57bfd34 100644 --- a/bashhub/version.py +++ b/bashhub/version.py @@ -1,5 +1,5 @@ import platform -__version__ = '2.1.3' +__version__ = '2.2.0' version_str = 'Bashhub {0} (python {1})'.format(__version__, platform.python_version()) diff --git a/install-bashhub.sh b/install-bashhub.sh index 6efada5..d9516b1 100755 --- a/install-bashhub.sh +++ b/install-bashhub.sh @@ -36,15 +36,31 @@ if [ -f ~/.bashrc ]; then fi ' -python_command=' +PYTHON_VERSION_COMMAND=' import sys -if (3, 5, 0) < sys.version_info < (3, 9, 0): +if (3, 5, 0) < sys.version_info < (3, 11, 0): sys.exit(0) -elif (2, 7, 0) < sys.version_info < (3,0): +elif (2, 7, 8) < sys.version_info < (3,0): sys.exit(0) else: sys.exit(-1)' +# Prefer Python 3 versions over Python 2 +PYTHON_VERSION_ARRAY=( + "/usr/bin/python3" + "python3" + "python3.10" + "python3.9" + "python3.8" + "python3.7" + "python3.6" + "python3.5" + "python" + "python2.7" + "python27" + "python2" +) + bashhub_config=~/.bashhub/config backup_config=~/.bashhub.config.backup zshprofile=~/.zshrc @@ -52,7 +68,7 @@ fish_config="${XDG_CONFIG_HOME:-~/.config}/fish/config.fish" # Optional parameter to specify a github branch # to pull from. -github_branch=${1:-'2.1.3'} +github_branch=${1:-'2.2.0'} install_bashhub() { check_dependencies @@ -61,12 +77,10 @@ install_bashhub() { } get_and_check_python_version() { - # Prefer Python 3 versions over python 2 - python_version_array=( "python3.8" "python3.7" "python3.6" "python3.5" "python3" "python" "python2.7" "python27" "python2") - for python_version in "${python_version_array[@]}"; do + for python_version in "${PYTHON_VERSION_ARRAY[@]}"; do if type "$python_version" &> /dev/null; then - if "$python_version" -c "$python_command"; then + if "$python_version" -c "$PYTHON_VERSION_COMMAND"; then echo "$python_version" return 0 fi @@ -76,40 +90,31 @@ get_and_check_python_version() { return 1 } +# Boostrap virtualenv via zipapp +# Details https://virtualenv.pypa.io/en/latest/installation.html#via-zipapp download_and_install_env() { - # Select current version of virtualenv: - VERSION=16.7.10 - # Name your first "bootstrap" environment: - INITIAL_ENV="env" - # Options for your first environment: - ENV_OPTS="--distribute" - - # Only supporting 2.7 right now. - python_command=$(get_and_check_python_version) + local python_command=$(get_and_check_python_version) if [[ -z "$python_command" ]]; then - die "\n Sorry you need to have python 3.5-3.8 or 2.7 installed. Please install it and rerun this script." 1 + 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 fi # Set to whatever python interpreter you want for your first environment PYTHON=$(which $python_command) - URL_BASE=https://pypi.python.org/packages/source/v/virtualenv - - # --- Real work starts here --- - curl -OL $URL_BASE/virtualenv-$VERSION.tar.gz - tar xzf virtualenv-$VERSION.tar.gz - - # Create the first "bootstrap" environment. echo "Using Python path $PYTHON" - $PYTHON virtualenv-$VERSION/virtualenv.py "$ENV_OPTS" "$INITIAL_ENV" - # Remove our virtual env setup files we don't need anymore - rm -rf virtualenv-$VERSION - rm virtualenv-$VERSION.tar.gz + VERSION=20.10.0 + VERSION_URL="https://github.com/pypa/get-virtualenv/raw/$VERSION/public/virtualenv.pyz" + # Alternatively use latest url for most recent that should be 2.7-3.9+ + LATEST_URL="https://bootstrap.pypa.io/virtualenv/2.7/virtualenv.pyz" + curl -OL $VERSION_URL + # Create the first "bootstrap" environment. + $PYTHON virtualenv.pyz -q env + rm virtualenv.pyz } check_dependencies() { if [ -z "$(get_and_check_python_version)" ]; then - die "\n Sorry can't seem to find a version of python 3.5-3.8 or 2.7 installed" 1 + die "\n Sorry can't seem to find a version of python 3.5-3.10 or 2.7.9+ installed" 1 fi if [ -z "$(detect_shell_type)" ]; then diff --git a/setup.py b/setup.py index f359ff3..1bbdc0e 100644 --- a/setup.py +++ b/setup.py @@ -16,10 +16,10 @@ packages=find_packages(), include_package_data=True, install_requires=[ - 'requests==2.23.0', 'jsonpickle==0.7.0', 'click==3.3', + 'requests==2.23.0', 'jsonpickle==2.0.0', 'click==6.7', 'npyscreen==4.10.5', 'python-dateutil==2.8.1', 'pyCLI==2.0.3', 'pymongo==3.10.1', 'inflection==0.3.1', 'humanize==1.0.0', - 'future==0.16.0', 'mock==3.0.5' + 'future==0.18.2', 'mock==3.0.5' ], tests_require=tests_require, extras_require={'test': tests_require}, diff --git a/tests/shell/install-bashhub.bats b/tests/shell/install-bashhub.bats index c1547e1..2815046 100644 --- a/tests/shell/install-bashhub.bats +++ b/tests/shell/install-bashhub.bats @@ -31,6 +31,8 @@ setup() { @test "get_and_check_python_version should find python3 first" { # Mock up some fake responses here. + python3.10() { return 1; } + python3.9() { return 1; } python3.8() { return 1; } python3.7() { return 1; } python3.6() { return 1; } @@ -53,6 +55,8 @@ setup() { # Mock up some fake responses here. python3() { return 1; } + python3.10() { return 1; } + python3.9() { return 1; } python3.8() { return 1; } python3.7() { return 1; } python3.6() { return 1; }