HGStyle revised this gist 9 months ago. Go to revision
1 file changed, 26 insertions
pip_apt_fix.sh(file created)
| @@ -0,0 +1,26 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | ||
| 3 | + | # Define the pip config directory and file | |
| 4 | + | PIP_CONFIG_DIR="$HOME/.config/pip" | |
| 5 | + | PIP_CONFIG_FILE="$PIP_CONFIG_DIR/pip.conf" | |
| 6 | + | ||
| 7 | + | # Create the config directory if it doesn't exist | |
| 8 | + | mkdir -p "$PIP_CONFIG_DIR" | |
| 9 | + | ||
| 10 | + | # Add or update the break-system-packages option | |
| 11 | + | if grep -q "^\[install\]" "$PIP_CONFIG_FILE" 2>/dev/null; then | |
| 12 | + | # [install] section exists; update or append the option | |
| 13 | + | if grep -q "^break-system-packages" "$PIP_CONFIG_FILE"; then | |
| 14 | + | sed -i 's/^break-system-packages.*/break-system-packages = true/' "$PIP_CONFIG_FILE" | |
| 15 | + | else | |
| 16 | + | sed -i '/^\[install\]/a break-system-packages = true' "$PIP_CONFIG_FILE" | |
| 17 | + | fi | |
| 18 | + | else | |
| 19 | + | # Add the [install] section and the option | |
| 20 | + | { | |
| 21 | + | echo "[install]" | |
| 22 | + | echo "break-system-packages = true" | |
| 23 | + | } >> "$PIP_CONFIG_FILE" | |
| 24 | + | fi | |
| 25 | + | ||
| 26 | + | echo "✅ pip is now configured to use --break-system-packages by default." | |
Newer
Older