-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathbuild.sh
executable file
·83 lines (70 loc) · 2.36 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
81
82
83
#!/bin/bash
# Build packages for distribution on PyPI
# and execute some sanity scripts on them
#
# note: must be executed from the root directory of the project
# first clean up the local environment
echo "..... Clean up first"
find . -type f -name '*.pyc' -delete
find . -type d -name __pycache__ -delete
find . -type d -name '*.egg-info' | xargs rm -rf
rm -rf build/ .cache/ dist/ .eggs/ .tox/
# check rst formatting of README/CHANGELOG before building the package
echo "..... Check rst formatting for PyPI"
tox -e readme
# then build the packages
echo "..... Building PyPI packages"
set -e
poetry build --quiet
set +e
# then run some sanity tests
echo "..... Searching for .pyc files inside the built packages"
matched_files=`tar -tvf dist/*.tar.gz | grep -c "\.pyc"`
if [ "$matched_files" -gt "0" ]; then
echo "ERROR: .pyc files found in .tar.gz package"
exit 1
fi
matched_files=`unzip -t dist/*.whl | grep -c "\.pyc"`
if [ "$matched_files" -gt "0" ]; then
echo "ERROR: .pyc files found in wheel package"
exit 1
fi
echo "..... Trying to verify that all source files are present"
# remove pylint_django/*.egg-info/ generated during build
find . -type d -name '*.egg-info' | xargs rm -rf
source_files=`find ./pylint_django/ -type f ! -path '**/tests/**' | sed 's|./||'`
# verify for .tar.gz package
package_files=`tar -tvf dist/*.tar.gz`
for src_file in $source_files; do
echo "$package_files" | grep $src_file >/dev/null
if [ "$?" -ne 0 ]; then
echo "ERROR: $src_file not found inside tar.gz package"
exit 1
fi
done
# verify for wheel package
package_files=`unzip -t dist/*.whl`
for src_file in $source_files; do
echo "$package_files" | grep $src_file >/dev/null
if [ "$?" -ne 0 ]; then
echo "ERROR: $src_file not found inside wheel package"
exit 1
fi
done
# exit on error from now on
set -e
echo "..... Trying to install the new tarball inside a virtualenv"
# note: installs with the optional dependency to verify this is still working
virtualenv .venv/test-tarball
source .venv/test-tarball/bin/activate
pip install -f dist/ pylint_django[with-django]
pip freeze | grep Django
deactivate
rm -rf .venv/
echo "..... Trying to install the new wheel inside a virtualenv"
virtualenv .venv/test-wheel
source .venv/test-wheel/bin/activate
pip install --only-binary :all: -f dist/ pylint_django
deactivate
rm -rf .venv/
echo "..... PASS"