Commit 8cb6eb36 authored by Your Name's avatar Your Name

feat: Add automatic --break-system-packages detection to build.sh

- Add pip_install() function that detects externally-managed-environment errors
- Automatically retry with --break-system-packages flag when needed
- Improves compatibility with modern Linux distributions that use PEP 668
parent 0c895e05
...@@ -34,11 +34,29 @@ if ! command -v python &> /dev/null; then ...@@ -34,11 +34,29 @@ if ! command -v python &> /dev/null; then
exit 1 exit 1
fi fi
# Function to run pip with --break-system-packages if needed
pip_install() {
# Try without --break-system-packages first
if pip install "$@" 2>&1 | grep -q "externally-managed-environment"; then
echo "System requires --break-system-packages flag, retrying..."
pip install --break-system-packages "$@"
elif ! pip install "$@" 2>&1; then
# If first attempt failed, check if it's the externally-managed error
if pip install "$@" 2>&1 | grep -q "externally-managed-environment"; then
echo "System requires --break-system-packages flag, retrying..."
pip install --break-system-packages "$@"
else
# Re-run to show the actual error
pip install "$@"
fi
fi
}
# Install build tools if not already installed # Install build tools if not already installed
echo "Checking for build tools..." echo "Checking for build tools..."
if ! python -m build --version &> /dev/null; then if ! python -m build --version &> /dev/null; then
echo "Installing build and twine..." echo "Installing build and twine..."
pip install build twine pip_install build twine
fi fi
# Clean previous builds # Clean previous builds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment