Update python scripts
pypi-release: install required venv dependencies venv: add support for per project .venv file
This commit is contained in:
parent
bcff049e0d
commit
f0a0bfed9a
|
@ -9,7 +9,7 @@ if [[ $? != 0 ]]; then
|
||||||
fi
|
fi
|
||||||
cd $root
|
cd $root
|
||||||
|
|
||||||
pip-venv-deps twine bump2version
|
pip-venv-deps twine bump2version setuptools wheel
|
||||||
|
|
||||||
if ! exists chronic; then
|
if ! exists chronic; then
|
||||||
echo "(chronic not found. install moreutils to only see relevant output)"
|
echo "(chronic not found. install moreutils to only see relevant output)"
|
||||||
|
|
38
misc/venv
38
misc/venv
|
@ -8,7 +8,9 @@ zparseopts -D -E \
|
||||||
n=newvenv -new=newvenv \
|
n=newvenv -new=newvenv \
|
||||||
t=tmsu -tmsu=tmsu \
|
t=tmsu -tmsu=tmsu \
|
||||||
p=pyenv -pyenv=pyenv \
|
p=pyenv -pyenv=pyenv \
|
||||||
f=find -find=find
|
f=find -find=find \
|
||||||
|
i=ignore -ignore-local=ignore \
|
||||||
|
s=save -save=save
|
||||||
|
|
||||||
if [[ $help ]]; then
|
if [[ $help ]]; then
|
||||||
<<-HELP
|
<<-HELP
|
||||||
|
@ -27,6 +29,11 @@ if [[ $help ]]; then
|
||||||
-f, --find Search for virtualenvs by looking for directories ending with 'venv'
|
-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
|
HELP
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -39,7 +46,7 @@ venvsh() {
|
||||||
if [[ -z $cdvenv ]]; then
|
if [[ -z $cdvenv ]]; then
|
||||||
cd $ORIGDIR
|
cd $ORIGDIR
|
||||||
fi
|
fi
|
||||||
$SHELL
|
exec $SHELL
|
||||||
}
|
}
|
||||||
|
|
||||||
pyenvsh() {
|
pyenvsh() {
|
||||||
|
@ -47,9 +54,26 @@ pyenvsh() {
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
eval "$(pyenv virtualenv-init -)"
|
eval "$(pyenv virtualenv-init -)"
|
||||||
pyenv activate "$1"
|
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
|
if [[ -n $tmsu ]]; then
|
||||||
venv=$(
|
venv=$(
|
||||||
for i in $(tmsu files --directory lang=python); do
|
for i in $(tmsu files --directory lang=python); do
|
||||||
|
@ -84,10 +108,10 @@ elif [[ ! $pyenv && $find ]]; then
|
||||||
else
|
else
|
||||||
venv=$(cat <(fd -I -t d 'venv$' $1) <(pyenvs) | fzf)
|
venv=$(cat <(fd -I -t d 'venv$' $1) <(pyenvs) | fzf)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $venv ]]; then
|
if [[ -n $venv ]]; then
|
||||||
if [[ $venv =~ pyenv\!* ]]; then
|
if [[ -n $save ]]; then
|
||||||
exec pyenvsh ${venv##pyenv!}
|
echo $venv > .venv
|
||||||
else
|
|
||||||
exec venvsh $venv
|
|
||||||
fi
|
fi
|
||||||
|
envsh $venv
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue