Change in vdsm[master]: makefile: Run pep8/pyflakes inside virtualenv

dkuznets at redhat.com dkuznets at redhat.com
Mon Aug 17 13:36:07 UTC 2015


Dima Kuznetsov has uploaded a new change for review.

Change subject: makefile: Run pep8/pyflakes inside virtualenv
......................................................................

makefile: Run pep8/pyflakes inside virtualenv

Since developers often don't use the same distribution, we cannot rely
on consistent version of pep8/pyflakes of developer/CI machines. This
patch introduces use of virtualenv so a specific version of the above
programs can be used.

Change-Id: I2ac3968ee6b2c9a1c9e3cf6bc78f486823bb6574
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1182088
Signed-off-by: Dima Kuznetsov <dkuznets at redhat.com>
---
M .gitignore
M Makefile.am
M vdsm.spec.in
3 files changed, 35 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/44928/1

diff --git a/.gitignore b/.gitignore
index 60bd094..ce47c06 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,3 +70,4 @@
 vdsm/rpc/vdsm-api.html
 vdsm_hooks/openstacknet/sudoers
 vdsm_hooks/persist-vdsm-hooks
+virtualenv/
diff --git a/Makefile.am b/Makefile.am
index 5633040..e9d63a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -113,30 +113,48 @@
 SKIP_PYFLAKES_ERR = "\./vdsm/storage/lvm\.py.*: list comprehension redefines \
 	'lv' from line .*"
 
+virtualenv:
+	virtualenv virtualenv
+
+PYFLAKES_VERSION=0.9.2
+PEP8_VERSION=1.5.6
+
 .PHONY: pyflakes
-pyflakes:
-	python -c 'import pyflakes; print("pyflakes-%s" % pyflakes.__version__)'
-	find . -path './.git' -prune -type f -o \
-		-name '*.py' -o -name '*.py.in' | \
-		echo $(WHITELIST) | xargs $(PYFLAKES) | \
-		grep -w -v $(SKIP_PYFLAKES_ERR) | \
-		while read LINE; do echo "$$LINE"; false; done
+pyflakes: virtualenv
+	(							\
+		source /tmp/vdsm-virtualenv/bin/activate ;	\
+		pip install pyflakes==$(PYFLAKES_VERSION) ;	\
+		find . -path './.git' -prune			\
+		        -path './virtualenv' -prune -type f -o 	\
+			-name '*.py' -o -name '*.py.in' | 	\
+			echo $(WHITELIST) | xargs pyflakes | \
+			grep -w -v $(SKIP_PYFLAKES_ERR) | 	\
+			while read LINE; do echo "$$LINE"; false; done \
+	)
 
 .PHONY: pep8
-pep8:
-	$(PEP8) --version
-	for x in $(PEP8_BLACKLIST); do \
-	    exclude="$${exclude},$${x}" ; \
-	done ; \
-	$(PEP8) --exclude="$${exclude}" --filename '*.py,*.py.in' . \
-	$(WHITELIST)
+pep8: virtualenv
+	(							\
+		source virtualenv/bin/activate ;	\
+		pip install pep8==$(PEP8_VERSION) ;		\
+		for x in $(PEP8_BLACKLIST); do 			\
+		    exclude="$${exclude},$${x}" ; 		\
+		done ; 						\
+		pep8 --version ; 				\
+		pep8 						\
+			--exclude="$${exclude}" 		\
+			--exclude='virtualenv/*'		\
+			--filename '*.py,*.py.in' 		\
+			. ;	 				\
+	)
+
 
 .PHONY: python3
 python3:
 	if [ -x "$(PYTHON3)" ]; then \
 	    PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) -m compileall \
 		$(WHITELIST) \
-		`find . -name '*.py' -o -name '*.py.in'`; \
+		`find . -path './virtualenv' -prune -name '*.py' -o -name '*.py.in'`; \
 	else \
 	    echo "Warning: skipping python3 syntax check"; \
 	fi
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 72e7df6..9410f02 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -75,6 +75,7 @@
 BuildRequires: python-netaddr
 BuildRequires: python-nose
 BuildRequires: python-six
+BuildRequires: python-virtualenv
 BuildRequires: rpm-build
 
 # BuildRequires needed by the tests during the build


-- 
To view, visit https://gerrit.ovirt.org/44928
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ac3968ee6b2c9a1c9e3cf6bc78f486823bb6574
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets at redhat.com>


More information about the vdsm-patches mailing list