source: Makefile @ 1499:f8ac6ddfcc1c

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