author Alexandre Poirot <>
Wed, 04 Nov 2015 08:56:00 +0100
changeset 307645 f4c516bc60ee0a50885a73c8e9a97b8bb8e58162
parent 286873 2eea7ab5228dde61fdc8706ea8452df10da6dd1d
permissions -rw-r--r--
Bug 1221238 - Fix devtools filter popup inputs width on linux. r=pbrosset

# Shortcuts for various tasks (UNIX only).
# To use a specific Python version run:
# $ make install PYTHON=python3.3

# You can set these variables from the command line.
PYTHON    = python
TSCRIPT   = test/

all: test

	rm -f `find . -type f -name \*.py[co]`
	rm -f `find . -type f -name \*.so`
	rm -f `find . -type f -name .\*~`
	rm -f `find . -type f -name \*.orig`
	rm -f `find . -type f -name \*.bak`
	rm -f `find . -type f -name \*.rej`
	rm -rf `find . -type d -name __pycache__`
	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) build
	@# copies *.so files in ./psutil directory in order to allow
	@# "import psutil" when using the interactive interpreter from within
	@# this directory.
	$(PYTHON) build_ext -i

# useful deps which are nice to have while developing / testing
	python -c "import urllib2; \
			   r = urllib2.urlopen(''); \
			   open('/tmp/', 'w').write(;"
	$(PYTHON) /tmp/ --user
	rm /tmp/
	$(PYTHON) -m pip install --user --upgrade pip
	$(PYTHON) -m pip install --user --upgrade \
		coverage  \
		flake8 \
		ipaddress \
		ipdb \
		mock==1.0.1 \
		nose \
		pep8 \
		pyflakes \
		sphinx \
		sphinx-pypi-upload \
		unittest2 \

install: build
	$(PYTHON) install --user

	cd ..; $(PYTHON) -m pip uninstall -y -v psutil

test: install

test-process: install
	$(PYTHON) -m unittest -v test.test_psutil.TestProcess

test-system: install
	$(PYTHON) -m unittest -v test.test_psutil.TestSystemAPIs

test-memleaks: install
	$(PYTHON) test/

# Run a specific test by name; e.g. "make test-by-name disk_" will run
# all test methods containing "disk_" in their name.
# Requires "pip install nose".
test-by-name: install
	@$(PYTHON) -m nose test/ test/_* --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))

# Same as above but for script.
test-memleaks-by-name: install
	@$(PYTHON) -m nose test/ --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))

coverage: install
	# Note: coverage options are controlled by .coveragerc file
	rm -rf .coverage htmlcov
	$(PYTHON) -m coverage run $(TSCRIPT)
	$(PYTHON) -m coverage report
	@echo "writing results to htmlcov/index.html"
	$(PYTHON) -m coverage html
	$(PYTHON) -m webbrowser -t htmlcov/index.html

	@git ls-files | grep \\.py$ | xargs $(PYTHON) -m pep8

	@export PYFLAKES_NODOCTEST=1 && \
		git ls-files | grep \\.py$ | xargs $(PYTHON) -m pyflakes

	@git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8

# Upload source tarball on
upload-src: clean
	$(PYTHON) sdist upload

# Build and upload doc on
# Requires "pip install sphinx-pypi-upload".
	cd docs; make html
	$(PYTHON) upload_sphinx --upload-dir=docs/_build/html

# git-tag a new release
	git tag -a release-`python -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
	echo "done; now run 'git push --follow-tags' to push the new tag on the remote repo"

# install GIT pre-commit hook
	ln -sf ../../.git-pre-commit .git/hooks/pre-commit
	chmod +x .git/hooks/pre-commit