build: Add environment variable to set alternative venv path

This commit is contained in:
2023-08-29 10:39:01 +02:00
parent a5b728dc7c
commit ee32621dcf
4 changed files with 22 additions and 9 deletions

View File

@@ -5,23 +5,34 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
# Variables
PACKAGE = revpipyload
# If virtualenv exists, use it. If not, use PATH to find, except python3
SYSTEM_PYTHON = /usr/bin/python3
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON))
# Set path to create the virtual environment with package name
ifdef PYTHON3_VENV
VENV_PATH = $(PYTHON3_VENV)/$(PACKAGE)
else
VENV_PATH = venv
endif
# If virtualenv exists, use it. If not, use PATH to find commands
SYSTEM_PYTHON = python3
PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
all: build
.PHONY: all
## Environment
venv-info:
echo Using path: "$(VENV_PATH)"
exit 0
venv:
$(SYSTEM_PYTHON) -m venv venv
source venv/bin/activate && \
$(SYSTEM_PYTHON) -m venv "$(VENV_PATH)"
source $(VENV_PATH)/bin/activate && \
python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt
exit 0
.PHONY: venv
.PHONY: venv-info venv
## Build, install
build:
@@ -38,6 +49,6 @@ clean:
rm -rf build dist src/*.egg-info *.spec
clean-all: clean
rm -R venv
rm -R $(VENV_PATH)
.PHONY: clean clean-all