build: Add environment variable to set alternative venv path

Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
2023-08-26 10:34:51 +02:00
parent be03bbe6f3
commit a0b309ade0
3 changed files with 22 additions and 11 deletions

2
.idea/misc.xml generated
View File

@@ -6,7 +6,7 @@
<component name="ProjectPlainTextFileTypeManager"> <component name="ProjectPlainTextFileTypeManager">
<file url="file://$PROJECT_DIR$/src/revpicommander/locale/revpicommander_de.ts" /> <file url="file://$PROJECT_DIR$/src/revpicommander/locale/revpicommander_de.ts" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (revpicommander)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (revpicommander)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser"> <component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>

View File

@@ -6,7 +6,7 @@
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.9 (revpicommander)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.11 (revpicommander)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PackageRequirementsSettings"> <component name="PackageRequirementsSettings">

View File

@@ -8,15 +8,22 @@ APP_NAME = RevPi\ Commander
APP_IDENT = org.revpimodio.revpicommander APP_IDENT = org.revpimodio.revpicommander
APPLE_SIG = "Developer ID Application: Sven Sager (U3N5843D9K)" APPLE_SIG = "Developer ID Application: Sven Sager (U3N5843D9K)"
# If virtualenv exists, use it. If not, use PATH to find, except python3 # 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 SYSTEM_PYTHON = python3
PYTHON = $(or $(wildcard venv/bin/python), $(SYSTEM_PYTHON)) PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
SYSTEM_PYUIC5 = $(shell which pyuic5) SYSTEM_PYUIC5 = $(shell which pyuic5)
PYUIC5 = $(or $(wildcard venv/bin/pyuic5), $(SYSTEM_PYUIC5)) PYUIC5 = $(or $(wildcard $(VENV_PATH)/bin/pyuic5), $(SYSTEM_PYUIC5))
SYSTEM_PYRCC5 = $(shell which pyrcc5) SYSTEM_PYRCC5 = $(shell which pyrcc5)
PYRCC5 = $(or $(wildcard venv/bin/pyrcc5), $(SYSTEM_PYRCC5)) PYRCC5 = $(or $(wildcard $(VENV_PATH)/bin/pyrcc5), $(SYSTEM_PYRCC5))
SYSTEM_PYLUP5 = $(shell which pylupdate5) SYSTEM_PYLUP5 = $(shell which pylupdate5)
PYLUP5 = $(or $(wildcard venv/bin/pylupdate5), $(SYSTEM_PYLUP5)) PYLUP5 = $(or $(wildcard $(VENV_PATH)/bin/pylupdate5), $(SYSTEM_PYLUP5))
APP_VERSION = $(shell $(PYTHON) src/$(PACKAGE) --version) APP_VERSION = $(shell $(PYTHON) src/$(PACKAGE) --version)
@@ -25,14 +32,18 @@ all: build_ui build_rc build
.PHONY: all .PHONY: all
## Environment ## Environment
venv-info:
echo Using path: "$(VENV_PATH)"
exit 0
venv: venv:
$(SYSTEM_PYTHON) -m venv --system-site-packages venv $(SYSTEM_PYTHON) -m venv --system-site-packages "$(VENV_PATH)"
source venv/bin/activate && \ source $(VENV_PATH)/bin/activate && \
python3 -m pip install --upgrade pip && \ python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
exit 0 exit 0
.PHONY: venv .PHONY: venv-info venv
## Compile Qt UI files to python code ## Compile Qt UI files to python code
build_ui: build_ui:
@@ -115,6 +126,6 @@ clean:
rm -rf build dist src/*.egg-info *.spec rm -rf build dist src/*.egg-info *.spec
clean-all: clean clean-all: clean
rm -R venv rm -R $(VENV_PATH)
.PHONY: clean clean-all .PHONY: clean clean-all