source: Makefile @ 1489:0500f24778e2

Last change on this file since 1489:0500f24778e2 was 1489:0500f24778e2, checked in by Stefan Schwarzer <sschwarzer@…>, 7 years ago
Added Makefile target `tox-test`.
File size: 2.7 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 pylint docs clean register patch
37
38# Patch various files to refer to a new version.
39patch:
40        @echo "Patching files"
41        ${SED} "s/^__version__ = \".*\"/__version__ = \"${VERSION}\"/" \
42                ${SOURCE_DIR}/version.py
43        ${SED} "s/^:Version:   .*/:Version:   ${VERSION}/" \
44                ${DOC_DIR}/ftputil.txt
45        ${SED} "s/^:Date:      .*/:Date:      `date +"%Y-%m-%d"`/" \
46                ${DOC_DIR}/ftputil.txt
47        ${SED} "s/^Version: .*/Version: ${VERSION}/" PKG-INFO
48        ${SED} "s/(\/wiki\/Download\/ftputil-).*(\.tar\.gz)/\1${VERSION}\2/" \
49                PKG-INFO
50
51# Documentation
52vpath %.txt ${DOC_DIR}
53
54docs: ${DOC_SOURCES} ${DOC_TARGETS}
55
56%.html: %.txt
57        ${RST2HTML} --stylesheet-path=${STYLESHEET_PATH} --embed-stylesheet $< $@
58
59# Quality assurance
60test:
61        @echo "=== Running tests for ftputil ${VERSION} ===\n"
62        for file in $(TEST_FILES); \
63        do \
64                echo $$file ; \
65                PYTHONPATH=${PYTHONPATH} ${PYTHON_BINARY} $$file ; \
66        done
67
68tox-test:
69        # Gets settings from `tox.ini`
70        tox
71
72pylint:
73        pylint --rcfile=pylintrc ${PYLINT_OPTS} ${SOURCE_DIR}/*.py | less
74
75# Prepare everything for making a distribution tarball.
76dist: clean patch pylint docs
77        ${PYTHON_BINARY} setup.py sdist
78
79extdist: test dist register
80
81# Register package on PyPI.
82register:
83        @echo "Registering new version with PyPI"
84        ${PYTHON_BINARY} setup.py register
85
86# Remove files with `orig` suffix (caused by `hg revert`).
87cleanorig:
88        find ${PROJECT_DIR} -name '*.orig' -exec rm {} \;
89
90# Remove generated files (but no distribution packages).
91clean:
92        rm -f ${DOC_TARGETS}
93        # Use absolute path to ensure we delete the right directory.
94        rm -rf ${PROJECT_DIR}/build
95
96# Help testing test installations. Note that `pip uninstall`
97# doesn't work if the package wasn't installed with pip.
98remove_from_env:
99        rm -rf ${VIRTUAL_ENV}/doc/ftputil
100        rm -rf ${VIRTUAL_ENV}/lib/python2.7/site-packages/ftputil
Note: See TracBrowser for help on using the repository browser.