Compare commits
6 Commits
jbomb-auto
...
43350eaa41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43350eaa41 | ||
|
|
782ef16107 | ||
|
|
0edc8467fd | ||
|
|
a8ecdb60a5 | ||
|
|
928e8b2d2d | ||
| eb96776e3c |
4
jconf
4
jconf
@@ -47,7 +47,7 @@ fi
|
||||
|
||||
cmd=$1
|
||||
case "$cmd" in
|
||||
adduser)
|
||||
adduser|mku)
|
||||
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
|
||||
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
|
||||
if [ "$exist" -eq 1 ]; then
|
||||
@@ -71,7 +71,7 @@ case "$cmd" in
|
||||
fi
|
||||
exit 1
|
||||
;;
|
||||
deluser)
|
||||
deluser|rmu)
|
||||
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
|
||||
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
|
||||
if [ "$exist" -eq 0 ]; then
|
||||
|
||||
24
penv
Normal file → Executable file
24
penv
Normal file → Executable file
@@ -12,13 +12,14 @@ usage() {
|
||||
echo ""
|
||||
echo "Usage: penv <command> <args>"
|
||||
echo "Commands:"
|
||||
echo " - new <name> <opt:version> - Create a new environment, optional, defaults to system's default python"
|
||||
echo " - new <name> <ver=default> - Create a new environment, optional, defaults to system's default python"
|
||||
echo " ex: penv new tools 3.13 -> creates new environment by the name tools, using Python 3.13"
|
||||
echo " ex: penv new main -> creates new env with the name main, using the default Python version on the system"
|
||||
echo " - del <name> - Delete existing environment"
|
||||
# echo " - setdef <name> - Use an existing environment as the default kernel"
|
||||
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
|
||||
echo " - list - List available environments"
|
||||
echo " - pylist - List available PYTHON versions"
|
||||
echo " - install - Initialize user's profile"
|
||||
echo " - uninstall - Remove ALL the environments installed using PENV"
|
||||
echo " - help - Print this message"
|
||||
@@ -28,6 +29,7 @@ usage() {
|
||||
echo " - del -> rm"
|
||||
# echo " - setdef -> sd"
|
||||
echo " - activate -> ac, act"
|
||||
echo " - pylist -> pyls"
|
||||
echo " - list -> ls"
|
||||
}
|
||||
|
||||
@@ -62,8 +64,8 @@ create(){
|
||||
mkdir -p "$HOME"/.envs
|
||||
/usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name"
|
||||
source "$HOME"/.envs/"$name"/bin/activate
|
||||
python -m pip install ipykernel ipywidgets > /dev/stderr
|
||||
python -m ipykernel install --user --name "$name" > /dev/stderr
|
||||
python -m pip install ipykernel ipywidgets
|
||||
python -m ipykernel install --user --name "$name"
|
||||
echo
|
||||
echo "Created \"$name\". It should be available as a Jupyter Kernel."
|
||||
echo "Use \"pact $name\" to activate in command line."
|
||||
@@ -84,12 +86,14 @@ delete(){
|
||||
read -r -n 1 -p "Remove environment $name (y/N)? " choise
|
||||
case $choise in
|
||||
[yY])
|
||||
size=$(du "$HOME"/.envs/"$name" -sh | cut -f1)
|
||||
source "$HOME"/.envs/"$name"/bin/activate
|
||||
echo
|
||||
echo Spec $(jupyter-kernelspec remove -f -y "$name")
|
||||
deactivate
|
||||
rm -r "$HOME/.envs/$name"
|
||||
echo "Data Removed $HOME/.envs/$name"
|
||||
echo "Reclaimed $size"
|
||||
;;
|
||||
[nN])
|
||||
echo ""
|
||||
@@ -130,6 +134,7 @@ install() {
|
||||
echo PENV already installed
|
||||
exit 10
|
||||
fi
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
cp $(realpath "$0") "$HOME"/.local/bin/
|
||||
mkdir -p "$HOME"/.envs/
|
||||
echo "
|
||||
@@ -176,6 +181,10 @@ uninstall() {
|
||||
echo "Uninstalled PENV"
|
||||
}
|
||||
|
||||
pyls(){
|
||||
find /usr/local/bin /usr/bin -name python3.* 2> /dev/null | tr " " "\n" | grep "3.*" --color=always
|
||||
}
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
title
|
||||
usage
|
||||
@@ -186,20 +195,23 @@ cmd=$1
|
||||
|
||||
case "$cmd" in
|
||||
new|mk)
|
||||
create "$2" "$3"
|
||||
create "$(echo "$2" | tr "[:upper:]" "[:lower:]")" "$3"
|
||||
;;
|
||||
del|rm)
|
||||
delete "$2"
|
||||
delete "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
|
||||
;;
|
||||
# setdef|sd)
|
||||
# setdef $2
|
||||
# ;;
|
||||
act|ac)
|
||||
activate "$2"
|
||||
activate "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
|
||||
;;
|
||||
list|ls)
|
||||
list
|
||||
;;
|
||||
pylist|pyls)
|
||||
pyls
|
||||
;;
|
||||
help)
|
||||
title
|
||||
usage
|
||||
|
||||
Reference in New Issue
Block a user