summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile50
1 files changed, 41 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index dead5612..2c9817a9 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,9 @@
PYTHON = python
TSCRIPT = test/test_psutil.py
+# Private vars
+COVERAGE_OPTS = --include="*psutil*" --omit="test/*,*setup*"
+
all: test
clean:
@@ -19,10 +22,12 @@ clean:
rm -rf *.core
rm -rf *.egg-info
rm -rf *\$testfile*
+ rm -rf .coverage
rm -rf .tox
rm -rf build
rm -rf dist
rm -rf docs/_build
+ rm -rf htmlcov
build: clean
$(PYTHON) setup.py build
@@ -31,6 +36,29 @@ build: clean
@# this directory.
$(PYTHON) setup.py build_ext -i
+# useful deps which are nice to have while developing / testing
+install-dev-deps:
+ python -c "import urllib2; \
+ r = urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py'); \
+ open('/tmp/get-pip.py', 'w').write(r.read());"
+ $(PYTHON) /tmp/get-pip.py --user
+ rm /tmp/get-pip.py
+ $(PYTHON) -m pip install --user --upgrade pip
+ $(PYTHON) -m pip install --user --upgrade \
+ # mandatory for unittests
+ ipaddress \
+ mock \
+ unittest2 \
+ # nice to have
+ coverage \
+ flake8 \
+ ipdb \
+ nose \
+ pep8 \
+ pyflakes \
+ sphinx \
+ sphinx-pypi-upload \
+
install: build
$(PYTHON) setup.py install --user; \
@@ -55,23 +83,27 @@ test-memleaks: install
test-by-name: install
@$(PYTHON) -m nose test/test_psutil.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))
-# same as above but for test_memory_leaks.py script
+# Same as above but for test_memory_leaks.py script.
test-memleaks-by-name: install
@$(PYTHON) -m nose test/test_memory_leaks.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))
-# requires "pip install pep8"
+coverage: install
+ rm -rf .coverage htmlcov
+ $(PYTHON) -m coverage run $(TSCRIPT) $(COVERAGE_OPTS)
+ $(PYTHON) -m coverage report $(COVERAGE_OPTS)
+ @echo "writing results to htmlcov/index.html"
+ $(PYTHON) -m coverage html $(COVERAGE_OPTS)
+ $(PYTHON) -m webbrowser -t htmlcov/index.html
+
pep8:
- @git ls-files | grep \\.py$ | xargs pep8
+ @git ls-files | grep \\.py$ | xargs $(PYTHON) -m pep8
-# requires "pip install pyflakes"
pyflakes:
@export PYFLAKES_NODOCTEST=1 && \
- git ls-files | grep \\.py$ | xargs pyflakes
+ git ls-files | grep \\.py$ | xargs $(PYTHON) -m pyflakes
-# requires "pip install flake8"
flake8:
- @git ls-files | grep \\.py$ | xargs flake8
-
+ @git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8
# Upload source tarball on https://pypi.python.org/pypi/psutil.
upload-src: clean
@@ -90,5 +122,5 @@ git-tag-release:
# install GIT pre-commit hook
install-git-hooks:
- cp .git-pre-commit .git/hooks/pre-commit
+ ln -sf ../../.git-pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit