source: Makefile @ 1710:c825f0cc96a3

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