-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython.mk
More file actions
131 lines (103 loc) · 4.05 KB
/
Python.mk
File metadata and controls
131 lines (103 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2020 Telefonica Investigacion y Desarrollo, S.A.U.
# Author: Alfred
# Project: script-tmpl
#
# This Makefile is used to generate different pyspark testing environments.
# Current pyspark versions supported:
# - PYPSARK 2.2, 2.3, 2.4, 3.0
PACKAGE_COVERAGE=$(PACKAGE_DIR)
PYPI_REPO?=
PYPI_REPO_USERNAME?=
PYPI_REPO_PASSWORD?=
ifneq "${PYPI_REPO_USERNAME}" ""
TWINE_OPS+= --username "$(PYPI_REPO_USERNAME)" --password "$(PYPI_REPO_PASSWORD)"
else
TWINE_OPS?=
endif
ifneq "${PYPI_REPO}" ""
TWINE_OPS+= --repository-url "${PYPI_REPO}"
endif
# Minimum coverage
COVER_MIN_PERCENTAGE=70
# Recipes ************************************************************************************
.PHONY: run-tests build clean beautify publish requirements all-requirements \
flake autopep sort-imports relative-imports python-help prepush pull-request
python-help:
@echo "Python options"
@echo "-----------------------------------------------------------------------"
@echo "python-help: This help"
@echo "run-tests: Run tests with coverage"
@echo "clean: Clean compiled files"
@echo "flake: Run Flake8"
@echo "prepush: Helper to run before to push to repo"
@echo "autopep: Reformat code using PEP8"
@echo "sort-imports: Sort imports"
@echo "beautify: Reformat code (autopep + sort-imports)"
@echo "build: Build python package"
@echo "publish: Publish new version in repository"
@echo "requirements: Install package base requirements"
@echo "requirements-dev: Install development package requirements"
@echo "requirements-lint: Install lint requirements"
@echo "requirements-package: Install requirements in order to build and publish package"
@echo "requirements-docs: Install documentation requirements"
@echo "all-requirements: Install all requirements"
@echo "get-version: Prints current version"
@echo "increase-version.{level}: Increase version using level which can be 'bugfix', 'minor' or 'major'"
# Code recipes
requirements:
@echo "Installing base requirements..."
python3 -m pip install -r requirements.txt
requirements-%: requirements
@echo "Installing requirements ${*}..."
python3 -m pip install -r requirements-${*}.txt
all-requirements: requirements requirements-lint requirements-package \
requirements-dev requirements-docs
@echo "All requirements installed"
build:
python3 setup.py bdist_wheel
publish: build
@echo "Publishing new ${PACKAGE_NAME} version on HI Artifactory's PyPi..."
@echo ${TWINE_OPS}
twine upload $(TWINE_OPS) dist/*.whl
autopep:
autopep8 --max-line-length 120 -a -r -j 8 -i .
flake:
@echo "Running flake8 tests..."
flake8 ${PACKAGE_COVERAGE}
flake8 tests
# flake8 docs/source
isort -c ${ISORT_PARAMS} ${PACKAGE_COVERAGE}
isort -c ${ISORT_PARAMS} tests
isort -c ${ISORT_PARAMS} setup.py
# isort -c ${ISORT_PARAMS} docs/source
run-tests:
@echo "Running unit tests..."
nose2 --fail-fast --with-coverage --coverage-report term-missing --coverage=${PACKAGE_COVERAGE} -vv
prepush: flake run-tests
pull-request: flake run-tests
sort-imports:
isort ${ISORT_PARAMS} ${PACKAGE_COVERAGE}
isort ${ISORT_PARAMS} tests
isort ${ISORT_PARAMS} setup.py setup_utils.py
# isort ${ISORT_PARAMS} docs/source
relative-imports:
absolufy-imports --never $(shell find . -name "*.py" -not -path "./.build/*")
beautify: autopep relative-imports sort-imports
# Clean files and directories created when testing or running pyspark
clean:
@echo "Cleaning compiled files..."
find . | grep -E "(__pycache__|\.pyc|\.pyo|pytest_cache)$ " | xargs rm -rf
@echo "Cleaning distribution files..."
rm -rf dist
@echo "Cleaning build files..."
rm -rf build
@echo "Cleaning egg info files..."
rm -rf ${PACKAGE_NAME}.egg-info
@echo "Cleaning coverage files..."
rm -f .coverage
increase-version.%:
python3 setup_utils.py increase-version --level ${*}
get-version:
@python3 setup_utils.py get-version
check-setup:
@python3 setup.py check -r -s