-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_build.sh
executable file
·80 lines (65 loc) · 2.57 KB
/
_build.sh
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
#!/usr/bin/env bash
###############################################################################
#
# Build script for [pyutilities] project (library).
# Script can be run from outside of virtual (pipenv) environment (from the
# system shell) and from the pipenv environment as well (pipenv shell).
#
# Created: Dmitrii Gusev, 30.11.2021
# Modified: Dmitrii Gusev, 06.05.2024
#
# cspell:ignore pyutilities, isort
#
###############################################################################
# -- safe bash scripting - fail-fast pattern (google for more info)
set -euf -o pipefail
# -- set up encoding/language
export LANG="en_US.UTF-8"
# -- verbose output mode (on/off)
VERBOSE="--verbose"
# -- build directories
BUILD_DIR='build/'
DIST_DIR='dist/'
clear
printf "Build of [PyUtilities] library is starting...\n"
sleep 2
# -- I. Clean build and distribution folders
printf "\n\n *** Clearing temporary directories *** \n\n"
printf "\nDeleting [%s]...\n" ${BUILD_DIR}
rm -r ${BUILD_DIR} || printf "%s doesn't exist!\n" ${BUILD_DIR}
printf "\nDeleting [%s]...\n" ${DIST_DIR}
rm -r ${DIST_DIR} || printf "%s doesn't exist!\n" ${DIST_DIR}
# -- II. Clean caches and sync + lock pipenv dependencies
printf "\n\n *** Cleaning pipenv cache and update dependencies ***\n\n"
pipenv clean ${VERBOSE}
pipenv update --outdated ${VERBOSE} || printf "Packages check is done!\n\n" # list of outdated packages
pipenv update --dev --clear ${VERBOSE} # run lock, then sync
# -- III. Executing [black] code formatter
printf "\n\n *** Executing [black] automatic code formatter *** \n\n"
pipenv run black src/ ${VERBOSE} --config .black
pipenv run black tests/ ${VERBOSE} --config .black
sleep 3
# -- IV. Executing [mypy] types checker
printf "\n\n *** Executing [mypy] types checker *** \n\n"
pipenv run mypy src/
pipenv run mypy tests/
sleep 3
# -- V. Executing [flake8] for checking code formatting
printf "\n\n *** Executing [flake8] code format checker *** \n\n"
pipenv run flake8 src/
pipenv run flake8 tests/
sleep 3
# -- VI. Executing [isort] utility (imports sorting)
printf "\n\n *** Executing [isort] utility *** \n\n"
pipenv run isort --atomic .
sleep 3
# -- VII. Executing pytest with pytest-cov (see config - pytest.ini/setup.cfg)
printf "\n\n *** Executing tests *** \n\n"
pipenv run pytest tests/
sleep 3
# -- VIII. Building library distribution: binary whl and source archive (tar.gz),
# -- see options: -s -> tar.gz, -w -> whl (binary distribution)
printf "\n\n *** Building distribution for [PyUtilities] library *** \n\n"
pipenv run python -m build -s -w
printf "\nBuild finished.\n\n"
sleep 5