Skip to content

Commit

Permalink
autoenv: make Python version choices configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jhermann committed Jul 10, 2020
1 parent 76a0c41 commit ef3da93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
_venv_virtualenv="/usr/bin/python3 -m venv"
_venv_py3=true
_venv_choices=('$_venv_py_tk' 3.9 3.8 3.7 3.6 3.5 3)
_venv_pip_req='pip>20'
_venv_bin=bin
_venv_master_url="https://raw.githubusercontent.com/Springerle/py-generic-project/master/.env"
Expand All @@ -37,8 +38,8 @@ elif $_venv_py3; then # Python 3 mode?
# python3 venv in recent Debian / Ubuntu
# prefer a version that has Tkinter installed, if available
_venv_py_tk=$(dpkg-query -W -f '${Version}\n' 'python3*-tk' 2>/dev/null | sort -rV | head -n1 | cut -f-2 -d.)
for _venv_temp in $_venv_py_tk 3.9 3.8 3.7 3.6 3.5 3; do
_venv_temp=/usr/bin/python$_venv_temp
for _venv_temp in "${_venv_choices[@]}"; do
_venv_temp="/usr/bin/python$(eval echo $_venv_temp)"
if test -x $_venv_temp; then
_venv_virtualenv="$_venv_temp -m venv"
break
Expand Down Expand Up @@ -221,6 +222,6 @@ elif pwd -P | egrep -v '/{''{''.*''}''}(/|$)' >/dev/null || $_venv_create; then
fi

unset _venv_script _venv_bin _venv_name _venv_ask _venv_create _venv_develop _venv_pip_log _venv_base _venv_py_tk
unset _venv_readlink _venv_temp _venv_virtualenv _venv_verbose _venv_py3 _venv_pip_req _venv_master_url
unset _venv_readlink _venv_temp _venv_virtualenv _venv_verbose _venv_py3 _venv_pip_req _venv_master_url _venv_choices
eval $_venv_xtrace # restore xtrace state
unset _venv_xtrace
7 changes: 4 additions & 3 deletions {{cookiecutter.repo_name}}/.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
_venv_virtualenv="/usr/bin/python3 -m venv"
_venv_py3=true
_venv_choices=('$_venv_py_tk' 3.9 3.8 3.7 3.6 3.5 3)
_venv_pip_req='pip>20'
_venv_bin=bin
_venv_master_url="https://raw.githubusercontent.com/Springerle/py-generic-project/master/.env"
Expand All @@ -37,8 +38,8 @@ elif $_venv_py3; then # Python 3 mode?
# python3 venv in recent Debian / Ubuntu
# prefer a version that has Tkinter installed, if available
_venv_py_tk=$(dpkg-query -W -f '${Version}\n' 'python3*-tk' 2>/dev/null | sort -rV | head -n1 | cut -f-2 -d.)
for _venv_temp in $_venv_py_tk 3.9 3.8 3.7 3.6 3.5 3; do
_venv_temp=/usr/bin/python$_venv_temp
for _venv_temp in "${_venv_choices[@]}"; do
_venv_temp="/usr/bin/python$(eval echo $_venv_temp)"
if test -x $_venv_temp; then
_venv_virtualenv="$_venv_temp -m venv"
break
Expand Down Expand Up @@ -221,6 +222,6 @@ elif pwd -P | egrep -v '/{''{''.*''}''}(/|$)' >/dev/null || $_venv_create; then
fi

unset _venv_script _venv_bin _venv_name _venv_ask _venv_create _venv_develop _venv_pip_log _venv_base _venv_py_tk
unset _venv_readlink _venv_temp _venv_virtualenv _venv_verbose _venv_py3 _venv_pip_req _venv_master_url
unset _venv_readlink _venv_temp _venv_virtualenv _venv_verbose _venv_py3 _venv_pip_req _venv_master_url _venv_choices
eval $_venv_xtrace # restore xtrace state
unset _venv_xtrace

0 comments on commit ef3da93

Please sign in to comment.