Fetching contributors…
Cannot retrieve contributors at this time
184 lines (152 sloc) 5.49 KB
# Shortcuts for various tasks (UNIX only).
# To use a specific Python version run:
# $ make install PYTHON=python3.3
PYTHON = python
TSCRIPT = pyftpdlib/test/
check-manifest \
coverage \
flake8 \
mock==1.0.1 \
pep8 \
pyflakes \
setuptools \
nose \
psutil \
pyopenssl \
pysendfile \
# In not in a virtualenv, add --user options for install commands.
INSTALL_OPTS = `$(PYTHON) -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')"`
all: test
clean: ## Remove all build files.
rm -rf `find . -type d -name __pycache__ \
-o -type f -name \*.bak \
-o -type f -name \*.orig \
-o -type f -name \*.pyc \
-o -type f -name \*.pyd \
-o -type f -name \*.pyo \
-o -type f -name \*.rej \
-o -type f -name \*.so \
-o -type f -name \*.~ \
-o -type f -name \*\$testfn`
rm -rf \
*.core \
*.egg-info \
*\$testfile* \
.coverage \
.tox \
build/ \
dist/ \
docs/_build/ \
htmlcov/ \
install: ## Install this package.
# make sure setuptools is installed (needed for 'develop' / edit mode)
$(PYTHON) -c "import setuptools"
uninstall: ## Uninstall this package.
cd ..; $(PYTHON) -m pip uninstall -y -v pyftpdlib || true
$(PYTHON) scripts/
install-pip: ## (only if necessary)
$(PYTHON) -c \
"import sys, ssl, os, pkgutil, tempfile, atexit; \
sys.exit(0) if pkgutil.find_loader('pip') else None; \
pyexc = 'from urllib.request import urlopen' if sys.version_info[0] == 3 else 'from urllib2 import urlopen'; \
exec(pyexc); \
ctx = ssl._create_unverified_context() if hasattr(ssl, '_create_unverified_context') else None; \
kw = dict(context=ctx) if ctx else {}; \
req = urlopen('', **kw); \
data =; \
f = tempfile.NamedTemporaryFile(suffix='.py'); \
atexit.register(f.close); \
f.write(data); \
f.flush(); \
print('downloaded %s' %; \
code = os.system('%s %s --user' % (sys.executable,; \
f.close(); \
setup-dev-env: ## Install GIT hooks, pip, test deps (also upgrades them).
${MAKE} install-git-hooks
${MAKE} install-pip
$(PYTHON) -m pip install $(INSTALL_OPTS) --upgrade pip
$(PYTHON) -m pip install $(INSTALL_OPTS) --upgrade $(TEST_DEPS)
$(PYTHON) -m pip install $(INSTALL_OPTS) --upgrade $(DEV_DEPS)
test: ## Run all tests.
${MAKE} install
test-functional: ## Run functional FTP tests.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-functional-ssl: ## Run functional FTPS tests.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-servers: ## Run tests for FTPServer and its subclasses.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-authorizers: ## Run tests for authorizers.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-filesystems: ## Run filesystem tests.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-ioloop: ## Run IOLoop tests.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-misc: ## Run miscellaneous tests.
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) pyftpdlib/test/
test-by-name: ## e.g.: make test-by-name ARGS=pyftpdlib.test.test_functional.TestFtpStoreData
${MAKE} install
PYTHONWARNINGS=all $(PYTHON) -m unittest -v $(ARGS)
test-coverage: ## Run test coverage.
${MAKE} install
rm -rf .coverage htmlcov
PYTHONWARNINGS=all $(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
pep8: ## PEP8 linter.
@git ls-files | grep \\.py$ | xargs $(PYTHON) -m pep8
pyflakes: ## Pyflakes linter.
git ls-files | grep \\.py$ | xargs $(PYTHON) -m pyflakes
flake8: ## flake8 linter.
@git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8
check-manifest: ## Inspect file.
$(PYTHON) -m check_manifest -v $(ARGS)
upload-src: ## Upload source on PYPI.
${MAKE} clean
$(PYTHON) sdist upload
git-tag-release: ## Git-tag a new release.
git tag -a release-`python -c "import setup; print(setup.VERSION)"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
git push --follow-tags
install-git-hooks: ## Install GIT pre-commit hook
ln -sf ../../.git-pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
grep-todos: ## Look for TODOs in source files.
git grep -EIn "TODO|FIXME|XXX"
pre-release: ## All the necessary steps before making a release.
${MAKE} clean
$(PYTHON) -c \
"from pyftpdlib import __ver__ as ver; \
doc = open('docs/index.rst').read(); \
history = open('HISTORY.rst').read(); \
assert ver in history, '%r not in HISTORY.rst' % ver; \
assert 'XXXX' not in history; \
$(PYTHON) sdist
release: ## Creates a release (tar.gz + upload + git tag release).
${MAKE} pre-release
$(PYTHON) -m twine upload dist/* # upload tar on PYPI
${MAKE} git-tag-release
generate-manifest: ## Generates file.
$(PYTHON) scripts/ >
print-announce: ## Print announce of new release.
@$(PYTHON) scripts/
help: ## Display callable targets.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'