source: Makefile @ 1702:9d55cee384ec

Last change on this file since 1702:9d55cee384ec was 1702:9d55cee384ec, checked in by Stefan Schwarzer <sschwarzer@…>, 2 years ago
Increase year in copyright note
File size: 3.3 KB
Line 
1# Copyright (C) 2003-2017, Stefan Schwarzer <sschwarzer@sschwarzer.net>
2# and ftputil contributors (see `doc/contributors.txt`)
3# See the file LICENSE for licensing terms.
4
5# This Makefile requires GNU Make.
6
7SHELL=/bin/sh
8PROJECT_DIR=$(shell pwd)
9VERSION=$(shell cat VERSION)
10PYTHON_BINARY?=python2
11# Depending on the development system, this may be `pytest`, `py.test`
12# or even something else.
13PYTEST=pytest
14
15TEST_DIR=${PROJECT_DIR}/test
16
17SOURCE_DIR=${PROJECT_DIR}/ftputil
18
19DOC_DIR=${PROJECT_DIR}/doc
20STYLESHEET_PATH=${DOC_DIR}/default.css
21DOC_SOURCES=$(subst d/,${DOC_DIR}/, d/ftputil.txt \
22                          d/whats_new_in_ftputil_3.0.txt)
23DOC_TARGETS=$(subst d/,${DOC_DIR}/, d/ftputil.html \
24                          d/whats_new_in_ftputil_3.0.html)
25
26SED=sed -i'' -r -e
27
28PYTHONPATH=${PROJECT_DIR}:${TEST_DIR}
29
30#TODO Some platforms call that script rst2html.py - allow both.
31RST2HTML=rst2html
32
33# Name test files. Make sure the long-running tests come last.
34TEST_FILES=$(shell ls -1 ${TEST_DIR}/test_*.py | \
35                         grep -v "test_real_ftp.py" | \
36                         grep -v "test_public_servers.py" ) \
37                   ${TEST_DIR}/test_real_ftp.py \
38                   ${TEST_DIR}/test_public_servers.py
39
40.PHONY: dist extdist test tox_test coverage pylint \
41        find_missing_unicode_literals \
42        docs clean cleanorig upload patch remove_from_env
43
44# Patch various files to refer to a new version.
45patch:
46        @echo "Patching files"
47        ${SED} "s/^__version__ = \".*\"/__version__ = \"${VERSION}\"/" \
48                ${SOURCE_DIR}/version.py
49        ${SED} "s/^:Version:   .*/:Version:   ${VERSION}/" \
50                ${DOC_DIR}/ftputil.txt
51        ${SED} "s/^:Date:      .*/:Date:      `date +"%Y-%m-%d"`/" \
52                ${DOC_DIR}/ftputil.txt
53        ${SED} "s/^Version: .*/Version: ${VERSION}/" PKG-INFO
54        ${SED} "s/(\/wiki\/Download\/ftputil-).*(\.tar\.gz)/\1${VERSION}\2/" \
55                PKG-INFO
56
57# Documentation
58vpath %.txt ${DOC_DIR}
59
60docs: ${DOC_SOURCES} ${DOC_TARGETS}
61
62%.html: %.txt
63        ${RST2HTML} --stylesheet-path=${STYLESHEET_PATH} --embed-stylesheet $< $@
64
65# Quality assurance
66test:
67        @echo -e "=== Running fast tests for ftputil ${VERSION} ===\n"
68        ${PYTEST} -m "not slow_test" test
69
70# Alternative for symmetry with target `all_tests`
71tests: test
72
73all_tests:
74        @echo -e "=== Running all tests for ftputil ${VERSION} ===\n"
75        ${PYTEST} test
76
77tox_test:
78        # Gets settings from `tox.ini`
79        tox
80
81coverage:
82        py.test --cov ftputil --cov-report html test
83
84pylint:
85        pylint --rcfile=pylintrc ${PYLINT_OPTS} ${SOURCE_DIR}/*.py | less
86
87find_missing_unicode_literals:
88        find ftputil test -name "*.py" \
89          -exec grep -L "from __future__ import unicode_literals" {} \;
90
91# Make a distribution tarball.
92dist: clean patch pylint docs
93        ${PYTHON_BINARY} setup.py sdist
94
95extdist: all_tests dist upload
96
97# Upload package to PyPI.
98upload:
99        @echo "Uploading new version to PyPI"
100        ${PYTHON_BINARY} setup.py sdist upload
101
102# Remove files with `orig` suffix (caused by `hg revert`).
103cleanorig:
104        find ${PROJECT_DIR} -name '*.orig' -exec rm {} \;
105
106# Remove generated files (but no distribution packages).
107clean:
108        rm -f ${DOC_TARGETS}
109        # Use absolute path to ensure we delete the right directory.
110        rm -rf ${PROJECT_DIR}/build
111        find ${PROJECT_DIR} -type f -name "*.pyc" -exec rm {} \;
112        find ${PROJECT_DIR} -type d -name "__pycache__" -exec rm -r {} \;
113
114# Help testing test installations. Note that `pip uninstall`
115# doesn't work if the package wasn't installed with pip.
116remove_from_env:
117        rm -rf ${VIRTUAL_ENV}/doc/ftputil
118        rm -rf ${VIRTUAL_ENV}/lib/python2.7/site-packages/ftputil
Note: See TracBrowser for help on using the repository browser.