Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions scripts/envie
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ _ENVIE_USE_DB="0"
_ENVIE_DB_PATH="$_ENVIE_CONFIG_DIR/locate.db"
_ENVIE_CACHE_PATH="$_ENVIE_CONFIG_DIR/virtualenvs.list"
_ENVIE_INDEX_ROOT="$HOME"
_ENVIE_CRON_INDEX="0" # having periodical updatedb?
_ENVIE_CRON_PERIOD_MIN="15" # update period in minutes
_ENVIE_LS_INDEX="0" # updatedb on each lsenv?
_ENVIE_FIND_LIMIT_SEC="0.4" # abort find search if takes longer this (in seconds)
_ENVIE_LOCATE_LIMIT_SEC="4" # warn if index older than this (in seconds)
_ENVIE_CRON_INDEX="0" # having periodical updatedb?
_ENVIE_CRON_PERIOD_MIN="15" # update period in minutes
_ENVIE_LS_INDEX="0" # updatedb on each lsenv?
_ENVIE_FIND_LIMIT_SEC="0.4" # abort find search if takes longer this (in seconds)
_ENVIE_LOCATE_LIMIT_SEC="4" # warn if index older than this (in seconds)
_ENVIE_USE_PYVENV_FOR_PY3="0" # for py3, use pyvenv rather than slower virtualenv
_ENVIE_UUID="28d0b2c7bc5245d5b1278015abc3f0cd"
_ENVIE_VERSION="0.4.36-dev"

Expand All @@ -43,6 +44,7 @@ function _envie_dump_config() {
_ENVIE_LS_INDEX="$_ENVIE_LS_INDEX"
_ENVIE_FIND_LIMIT_SEC="$_ENVIE_FIND_LIMIT_SEC"
_ENVIE_LOCATE_LIMIT_SEC="$_ENVIE_LOCATE_LIMIT_SEC"
_ENVIE_USE_PYVENV_FOR_PY3="$_ENVIE_USE_PYVENV_FOR_PY3"
_ENVIE_UUID="$_ENVIE_UUID"
END
}
Expand Down Expand Up @@ -371,16 +373,25 @@ function mkenv() {
pip_valid_reqs+=("${pip_auto_reqs[@]}")
fi

local output virtualenv_opts=(--no-site-packages -p "$pypath")
local output virtualenv_cmd=virtualenv virtualenv_opts=(--no-site-packages -p "$pypath")

(( quietness > 0 )) && virtualenv_opts+=(-q)
(( verbosity > 1 )) && virtualenv_opts+=(-v)

if (( _ENVIE_USE_PYVENV_FOR_PY3 )) && [[ "$pyver" == "Python 3"* ]]; then
# use py3's built-in venv which is faster than virtualenv
virtualenv_cmd="${pypath}"
# and it doesn't support (or need) our regular opts, so clear them.
# no need to specify python because the one we launch will be used
# also it does not produce much output and hence doesn't support or need -q/-v opts.
virtualenv_opts=(-m venv)
fi

(
if (( verbosity > 0 )); then
virtualenv "${virtualenv_opts[@]}" "$@" "$envpath"
"$virtualenv_cmd" "${virtualenv_opts[@]}" "$@" "$envpath"
else
output=$(virtualenv "${virtualenv_opts[@]}" "$@" "$envpath" 2>&1)
output=$("$virtualenv_cmd" "${virtualenv_opts[@]}" "$@" "$envpath" 2>&1)
if (( $? )); then
(( quietness < 2 )) && _errmsg "$output"
exit 1
Expand Down Expand Up @@ -1036,6 +1047,12 @@ function __envie_config() {
_ENVIE_LS_INDEX=0
fi

read -p "Use pyvenv rather than virtualenv for python3 (faster) [y/N]? " ans
case "$ans" in
Y|y) _ENVIE_USE_PYVENV_FOR_PY3=1;;
*) _ENVIE_USE_PYVENV_FOR_PY3=0;;
esac

# add/remove source statement to/from .bashrc
(( add_to_bashrc )) && __envie_register || __envie_unregister

Expand Down