(Hopefully) Optimized python venv integration. If it leads to bugs, you know wehere to find them.

This commit is contained in:
Kevin Veen-Birkenbach
2025-07-24 18:46:39 +02:00
parent c26d5bf20f
commit 20065e88a0

View File

@@ -14,17 +14,14 @@ install:
@echo "Ensuring ~/.bashrc exists..." @echo "Ensuring ~/.bashrc exists..."
@test -f ~/.bashrc || touch ~/.bashrc @test -f ~/.bashrc || touch ~/.bashrc
@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 export VIRTUAL_ENV="$$HOME/.venvs/pkgmgr"; export PATH="$$VIRTUAL_ENV/bin:$$PATH"; unset PYTHONHOME; fi' ~/.bashrc \ @grep -qxF 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then . "$$HOME/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi' ~/.bashrc \
|| echo 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then export VIRTUAL_ENV="$$HOME/.venvs/pkgmgr"; export PATH="$$VIRTUAL_ENV/bin:$$PATH"; unset PYTHONHOME; fi' >> ~/.bashrc || echo 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then . "$$HOME/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi' >> ~/.bashrc
@grep -qxF 'echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."' ~/.bashrc \
|| echo 'echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."' >> ~/.bashrc
@echo "Installation complete. Please restart your shell (or 'exec bash') for the changes to take effect." @echo "Installation complete. Please restart your shell (or 'exec bash') 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 entries..."
@sed -i '/Global Python virtual environment '\''~\/.venvs\/pkgmgr'\'' activated\./d' ~/.bashrc @sed -i '/if \[ -d "\$\$HOME\/\.venvs\/pkgmgr" \]; then \. "\$\$HOME\/\.venvs\/pkgmgr\/bin\/activate"; echo "Global Python virtual environment '\\''~\/.venvs\/pkgmgr'\\'' activated."; fi/d' ~/.bashrc
@sed -i '/if \[ -d "\$\$HOME\/\.venvs\/pkgmgr" \]; then export VIRTUAL_ENV="\$\$HOME\/\.venvs\/pkgmgr"; export PATH="\$\$VIRTUAL_ENV\/bin:\$\$PATH"; unset PYTHONHOME; fi/d' ~/.bashrc
@echo "Uninstallation complete. Please restart your shell (or 'exec bash') for the changes to fully apply." @echo "Uninstallation complete. Please restart your shell (or 'exec bash') for the changes to fully apply."