From 74d423f23e6ca2fe515b2bd609a635b85557da32 Mon Sep 17 00:00:00 2001 From: Albert Esteve Date: Wed, 10 Aug 2022 09:37:22 +0200 Subject: [PATCH] Makefile: add venv target Add venv target to the Makefile, which automatically creates the Python virtual environment in a consistent folder and installs all requirements in a single step. Signed-off-by: Albert Esteve --- Makefile | 9 ++++++++- docs/development.md | 8 ++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 89137a81..c5a86932 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ PACKAGE_NAME=ovirt-imageio PACKAGE_VERSION=$(shell python3 ovirt_imageio/_internal/version.py) OUTDIR=dist +VENV_DIR = $(HOME)/.venv/ovirt-imageio + RPM_TOPDIR?=$(PWD)/build/rpm TAR_NAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz SPEC_NAME=$(PACKAGE_NAME).spec @@ -12,7 +14,7 @@ GENERATED = \ METADATA = ovirt_imageio/_internal/version.py Makefile -.PHONY: build check dist srpm rpm clean images clean-images storage clean-storage $(SPEC_NAME) +.PHONY: build check dist srpm rpm clean images clean-images storage clean-storage $(SPEC_NAME) venv build: python3 setup.py build_ext --build-lib . @@ -59,6 +61,11 @@ storage: clean-storage: userstorage delete storage.py +venv: + python3 -m venv $(VENV_DIR) && \ + $(VENV_DIR)/bin/python3 -m pip install --upgrade pip && \ + $(VENV_DIR)/bin/python3 -m pip install -r containers/requirements.txt + $(GENERATED) : % : %.in $(METADATA) @sed \ -e 's|@PACKAGE_NAME@|$(PACKAGE_NAME)|g' \ diff --git a/docs/development.md b/docs/development.md index 3a26f1a2..11b24d4b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -45,18 +45,14 @@ Install the runtime requirements: Create a virtual environment for running the tests: - python3 -m venv ~/venv/ovirt-imageio - source ~/venv/ovirt-imageio/bin/activate - pip install --upgrade pip - pip install --upgrade -r containers/requirements.txt - deactivate + make venv ## Running the tests Before running the tests, enter the virtual environment: - source ~/venv/ovirt-imageio/bin/activate + source ~/.venv/ovirt-imageio/bin/activate When you are done, you can deactivate the environment using: