From: Edward Delaporte Date: Mon, 6 Jul 2026 13:15:34 +0000 (-0500) Subject: Add support for python virtual envs X-Git-Url: https://apps.delaporte.us/gitweb/dotfiles.git/commitdiff_plain/9d039fd7e312d818f4b4f380541fd28ba19c5681?ds=inline Add support for python virtual envs --- diff --git a/bin/dot b/bin/dot index aa633ec..dc3e8fa 100755 --- a/bin/dot +++ b/bin/dot @@ -1,6 +1,14 @@ #!/bin/bash -ENVS="$HOME/envs" -ANSIBLE="$ENVS/ansible/bin/ansible-playbook" +ENVS="$HOME/envs" # Python environments - including required Ansible +ANSIBLE="$ENVS/ansible/bin/ansible-playbook" # Core command +TASKFILE="$HOME/backup/dot.$HOSTNAME.yaml" # Backup of localhost config +DOTFILES="$HOME/dotfiles" # Where to find dotfiles + +LINKFILES="$DOTFILES/files" # Files to symlink +INSTALLS="$DOTFILES/install" # Install scripts +DOT="$HOME/.dot" # Touched files go here to track installs +REQS="$DOTFILES/reqs" # Python env requirements.txt files + read -d '' HELP << EOF dot - a (mostly) one script dotfiles manager @@ -42,6 +50,9 @@ dot install SCRIPT to run ~/dotfiles/SCRIPT.sh if it has not yet been run creates ~/dot/SCRIPT.installed after SCRIPT has been run +dot env ENV + create Python environment ~/envs/ENV based on ~/dotfiles/reqs/ENV.txt + EOF @@ -62,10 +73,6 @@ fi # set -v # -TASKFILE="$HOME/backup/dot.$HOSTNAME.yaml" -LINKFILES="$HOME/dotfiles/files" -INSTALLS="$HOME/dotfiles/install" -DOT="$HOME/.dot" read -d '' EMPTY_TASKFILE << EOF --- @@ -152,7 +159,6 @@ fi echo "Run 'dot apply' to create all configured symlinks" fi - if [ "$1" == "apply" ]; then if [[ ! -f "$TASKFILE" ]]; then echo "$TASKFILE is missing. Run 'dot setup'" @@ -193,3 +199,38 @@ EOF echo " $RUN_INSTALL" >> $TASKFILE echo "Run 'dot apply' to run the install" fi + + +if [ "$1" == "env" ]; then + if [ ! -n "$2" ]; then + echo "Can create: (.txt files in $REQS)" + cd $REQS + ls -p | grep -v / | grep .txt + exit 1 + fi + if [[ ! -f "$REQS/$2.txt" ]]; then + echo "No such requirements file script $REQS/$2.txt" + echo "Run dot env with no params to list files." + exit 1 + fi + +read -d '' ADD_ENV << EOF + - name: check env $2 + stat: + path: "$ENVS/$2" + register: $2_path + - name: install $2 + ansible.builtin.shell: | + cd $ENVS + python3 -m venv $2 + $ENVS/$2/bin/python -m pip install -r $REQS/$2.txt + when: not $2_path.stat.exists + - name: verify env $2 exists + ansible.builtin.debug: + msg: "env $2 exists" + when: $2_path.stat.exists +EOF + echo " $ADD_ENV" >> $TASKFILE + echo "Run 'dot apply' to run the install" +fi +