source: Makefile @ 1497:a3fac26bf149

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