Skip to content

Commit

Permalink
Makefile: add venv target
Browse files Browse the repository at this point in the history
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 <aesteve@redhat.com>
  • Loading branch information
aesteve-rh authored and nirs committed Aug 11, 2022
1 parent ecc69d6 commit 74d423f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down Expand Up @@ -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' \
Expand Down
8 changes: 2 additions & 6 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 74d423f

Please sign in to comment.