Added virtual environment for python
This commit is contained in:
20
Makefile
20
Makefile
@@ -6,5 +6,21 @@ setup: install
|
|||||||
install:
|
install:
|
||||||
@echo "Making 'main.py' executable..."
|
@echo "Making 'main.py' executable..."
|
||||||
@chmod +x main.py
|
@chmod +x main.py
|
||||||
@echo "Installing packages from 'requirements.txt'..."
|
@echo "Checking if global user virtual environment exists..."
|
||||||
@pip install -r requirements.txt --break-system-packages
|
@test -d ~/.venvs/pkgmgr || (echo "Creating global venv at ~/.venvs/pkgmgr..." && python -m venv ~/.venvs/pkgmgr)
|
||||||
|
@echo "Installing required Python packages into ~/.venvs/pkgmgr..."
|
||||||
|
@~/.venvs/pkgmgr/bin/pip install --upgrade pip
|
||||||
|
@~/.venvs/pkgmgr/bin/pip install -r requirements.txt
|
||||||
|
@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 || echo 'if [ -d "$$HOME/.venvs/pkgmgr" ]; then export VIRTUAL_ENV="$$HOME/.venvs/pkgmgr"; export PATH="$$VIRTUAL_ENV/bin:$$PATH"; unset PYTHONHOME; 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."
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
@echo "Removing global user virtual environment if it exists..."
|
||||||
|
@rm -rf ~/.venvs/pkgmgr
|
||||||
|
@echo "Cleaning up ~/.bashrc entries..."
|
||||||
|
@sed -i '/Global Python virtual environment '\''~\/.venvs\/pkgmgr'\'' activated\./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."
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ def install_repos(
|
|||||||
req_txt_file = os.path.join(repo_dir, "requirements.txt")
|
req_txt_file = os.path.join(repo_dir, "requirements.txt")
|
||||||
if os.path.exists(req_txt_file):
|
if os.path.exists(req_txt_file):
|
||||||
print(f"requirements.txt found in {repo_identifier}, installing Python dependencies...")
|
print(f"requirements.txt found in {repo_identifier}, installing Python dependencies...")
|
||||||
cmd = "python3 -m pip install -r requirements.txt --break-system-packages"
|
cmd = "~/.venvs/pkgmgr/bin/pip install -r requirements.txt"
|
||||||
run_command(cmd, cwd=repo_dir, preview=preview)
|
run_command(cmd, cwd=repo_dir, preview=preview)
|
||||||
|
|
||||||
# Check if a Makefile exists and run make.
|
# Check if a Makefile exists and run make.
|
||||||
|
|||||||
Reference in New Issue
Block a user