Activated python venv for zsh und bash
This commit is contained in:
24
Makefile
24
Makefile
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: install setup
|
.PHONY: install setup uninstall
|
||||||
|
|
||||||
setup: install
|
setup: install
|
||||||
@python main.py install
|
@python main.py install
|
||||||
@@ -7,21 +7,25 @@ install:
|
|||||||
@echo "Making 'main.py' executable..."
|
@echo "Making 'main.py' executable..."
|
||||||
@chmod +x main.py
|
@chmod +x main.py
|
||||||
@echo "Checking if global user virtual environment exists..."
|
@echo "Checking if global user virtual environment exists..."
|
||||||
|
@mkdir -p ~/.venvs/pkgmgr
|
||||||
@test -d ~/.venvs/pkgmgr || (echo "Creating global venv at ~/.venvs/pkgmgr..." && python -m venv ~/.venvs/pkgmgr)
|
@test -d ~/.venvs/pkgmgr || (echo "Creating global venv at ~/.venvs/pkgmgr..." && python -m venv ~/.venvs/pkgmgr)
|
||||||
@echo "Installing required Python packages into ~/.venvs/pkgmgr..."
|
@echo "Installing required Python packages into ~/.venvs/pkgmgr..."
|
||||||
@~/.venvs/pkgmgr/bin/pip install --upgrade pip
|
@~/.venvs/pkgmgr/bin/pip install --upgrade pip
|
||||||
@~/.venvs/pkgmgr/bin/pip install -r requirements.txt
|
@~/.venvs/pkgmgr/bin/pip install -r requirements.txt
|
||||||
@echo "Ensuring ~/.bashrc exists..."
|
@echo "Ensuring ~/.bashrc and ~/.zshrc exist..."
|
||||||
@test -f ~/.bashrc || touch ~/.bashrc
|
@touch ~/.bashrc ~/.zshrc
|
||||||
@echo "Ensuring automatic activation of ~/.venvs/pkgmgr for this user..."
|
@echo "Ensuring automatic activation of ~/.venvs/pkgmgr for this user..."
|
||||||
@grep -qxF 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then . "$$HOME/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi' ~/.bashrc \
|
@for rc in ~/.bashrc ~/.zshrc; do \
|
||||||
|| echo 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then . "$$HOME/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi' >> ~/.bashrc
|
rc_line='if [ -d "$${HOME}/.venvs/pkgmgr" ]; then . "$${HOME}/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi'; \
|
||||||
@echo "Installation complete. Please restart your shell (or 'exec bash') for the changes to take effect."
|
grep -qxF "$${rc_line}" $$rc || echo "$${rc_line}" >> $$rc; \
|
||||||
|
done
|
||||||
|
@echo "Installation complete. Please restart your shell (or 'exec bash' or 'exec zsh') for the changes to take effect."
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "Removing global user virtual environment if it exists..."
|
@echo "Removing global user virtual environment if it exists..."
|
||||||
@rm -rf ~/.venvs/pkgmgr
|
@rm -rf ~/.venvs/pkgmgr
|
||||||
@echo "Cleaning up ~/.bashrc entries..."
|
@echo "Cleaning up ~/.bashrc and ~/.zshrc entries..."
|
||||||
@sed -i '/if \[ -d "\$\$HOME\/\.venvs\/pkgmgr" \]; then \. "\$\$HOME\/\.venvs\/pkgmgr\/bin\/activate"; echo "Global Python virtual environment '\\''~\/.venvs\/pkgmgr'\\'' activated."; fi/d' ~/.bashrc
|
@for rc in ~/.bashrc ~/.zshrc; do \
|
||||||
@echo "Uninstallation complete. Please restart your shell (or 'exec bash') for the changes to fully apply."
|
sed -i '/\.venvs\/pkgmgr\/bin\/activate"; echo "Global Python virtual environment '\''~\/\.venvs\/pkgmgr'\'' activated."; fi/d' $$rc; \
|
||||||
|
done
|
||||||
|
@echo "Uninstallation complete. Please restart your shell (or 'exec bash' or 'exec zsh') for the changes to fully apply."
|
||||||
|
|||||||
Reference in New Issue
Block a user