Skip to content

Commit

Permalink
Check if pip supports break systeem packages flag
Browse files Browse the repository at this point in the history
This commit adds changes to be backwards compatible with older bullseye builders where pip does not yet support break system packages flag.
  • Loading branch information
sonicaj committed Aug 21, 2023
1 parent 99012b3 commit 67287c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ PYTHON?=/usr/bin/python3
COMMIT_HASH=$(shell git rev-parse --short HEAD)
PACKAGES?=""
REPO_CHANGED=$(shell if [ -d "./venv-$(COMMIT_HASH)" ]; then git status --porcelain | grep -c "scale_build/"; else echo "1"; fi)
# Check if --break-system-packages flag is supported by pip
BREAK_SYS_PKGS_FLAG=$(shell ${PYTHON} -m pip help install | grep -q -- '--break-system-packages' && echo "--break-system-packages" || echo "")

.DEFAULT_GOAL := all

check:
ifneq ($(REPO_CHANGED),0)
@echo "Setting up new virtual environment"
@rm -rf venv-*
@${PYTHON} -m pip install --break-system-packages -U virtualenv >/dev/null || { echo "Failed to install/upgrade virtualenv package"; exit 1; }
@${PYTHON} -m pip install $(BREAK_SYS_PKGS_FLAG) -U virtualenv >/dev/null || { echo "Failed to install/upgrade virtualenv package"; exit 1; }
@${PYTHON} -m venv venv-${COMMIT_HASH} || { echo "Failed to create virutal environment"; exit 1; }
@{ . ./venv-${COMMIT_HASH}/bin/activate && \
python3 -m pip install -r requirements.txt >/dev/null 2>&1 && \
Expand Down

0 comments on commit 67287c3

Please sign in to comment.