Update python scripts

pypi-release: install required venv dependencies

venv: add support for per project .venv file
This commit is contained in:
Alexander Gehrke 2020-07-24 13:29:35 +02:00
parent bcff049e0d
commit f0a0bfed9a
2 changed files with 33 additions and 9 deletions

View file

@ -9,7 +9,7 @@ if [[ $? != 0 ]]; then
fi
cd $root
pip-venv-deps twine bump2version
pip-venv-deps twine bump2version setuptools wheel
if ! exists chronic; then
echo "(chronic not found. install moreutils to only see relevant output)"

View file

@ -8,7 +8,9 @@ zparseopts -D -E \
n=newvenv -new=newvenv \
t=tmsu -tmsu=tmsu \
p=pyenv -pyenv=pyenv \
f=find -find=find
f=find -find=find \
i=ignore -ignore-local=ignore \
s=save -save=save
if [[ $help ]]; then
<<-HELP
@ -26,7 +28,12 @@ if [[ $help ]]; then
-p, --pyenv Use pyenv virtualenvs
-f, --find Search for virtualenvs by looking for directories ending with 'venv'
If neither -p or -f are given, the default behaviour is to use both
If neither -p or -f are given, the default behaviour is to use both
-s, --save Store selected venv in .venv in current directory. Will be used
automatically, when called in this dir again.
-i, --ignore-local
Ignore .venv files.
HELP
exit
fi
@ -39,7 +46,7 @@ venvsh() {
if [[ -z $cdvenv ]]; then
cd $ORIGDIR
fi
$SHELL
exec $SHELL
}
pyenvsh() {
@ -47,9 +54,26 @@ pyenvsh() {
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate "$1"
$SHELL
exec $SHELL
}
envsh() {
local venv=$1
if [[ $venv =~ pyenv\!* ]]; then
pyenvsh ${venv##pyenv!}
else
venvsh $venv
fi
}
if [[ -z $ignore && -e .venv ]]; then
venv=$(<.venv)
echo "Local .venv found (-i to ignore)."
echo "Using: $venv"
envsh $venv
fi
if [[ -n $tmsu ]]; then
venv=$(
for i in $(tmsu files --directory lang=python); do
@ -84,10 +108,10 @@ elif [[ ! $pyenv && $find ]]; then
else
venv=$(cat <(fd -I -t d 'venv$' $1) <(pyenvs) | fzf)
fi
if [[ -n $venv ]]; then
if [[ $venv =~ pyenv\!* ]]; then
exec pyenvsh ${venv##pyenv!}
else
exec venvsh $venv
if [[ -n $save ]]; then
echo $venv > .venv
fi
envsh $venv
fi