pip_apt_fix.sh
· 874 B · Bash
Brut
#!/bin/bash
# Define the pip config directory and file
PIP_CONFIG_DIR="$HOME/.config/pip"
PIP_CONFIG_FILE="$PIP_CONFIG_DIR/pip.conf"
# Create the config directory if it doesn't exist
mkdir -p "$PIP_CONFIG_DIR"
# Add or update the break-system-packages option
if grep -q "^\[install\]" "$PIP_CONFIG_FILE" 2>/dev/null; then
# [install] section exists; update or append the option
if grep -q "^break-system-packages" "$PIP_CONFIG_FILE"; then
sed -i 's/^break-system-packages.*/break-system-packages = true/' "$PIP_CONFIG_FILE"
else
sed -i '/^\[install\]/a break-system-packages = true' "$PIP_CONFIG_FILE"
fi
else
# Add the [install] section and the option
{
echo "[install]"
echo "break-system-packages = true"
} >> "$PIP_CONFIG_FILE"
fi
echo "✅ pip is now configured to use --break-system-packages by default."
| 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." |