-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
check-build
executable file
·64 lines (54 loc) · 1.83 KB
/
check-build
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
#!/bin/bash
# Build packages for distribution on PyPI
# and execute some sanity checks 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/ .venv/
echo "..... Building PyPI packages for tcms-api"
set -e
$(which python) setup.py sdist >/dev/null
$(which python) setup.py bdist_wheel >/dev/null
set +e
# check rst formatting of README before building the package
echo "..... Check rst formatting for PyPI"
twine check dist/* || exit 1
# then run some sanity tests
echo "..... Searching for .pyc files inside the built packages"
matched_files=`tar -tvf dist/tcms-api-*.tar.gz | grep -c "\.pyc"`
if [ "$matched_files" -gt "0" ]; then
echo "ERROR: .pyc files found in .tar.gz package"
exit 1
fi
WHEEL_UNPACK_DIR=`mktemp -d`
wheel unpack --dest "$WHEEL_UNPACK_DIR" dist/tcms_api*.whl
matched_files=`find "$WHEEL_UNPACK_DIR" -type f | grep -c "\.pyc"`
rm -rf "$WHEEL_UNPACK_DIR"
if [ "$matched_files" -gt "0" ]; then
echo "ERROR: .pyc files found in wheel package"
exit 1
fi
# exit on error from now on
set -e
echo "..... Trying to install the new tarball inside a virtualenv"
virtualenv -q .venv/test-tarball
source .venv/test-tarball/bin/activate
pip install --upgrade setuptools pip
pip install --no-binary :all: -f dist/ tcms-api
pip freeze | grep tcms-api
deactivate
rm -rf .venv/
echo "..... Trying to install the new wheel inside a virtualenv"
virtualenv -q .venv/test-wheel
source .venv/test-wheel/bin/activate
pip install --upgrade setuptools pip
pip install kerberos
pip install --only-binary :all: -f dist/ tcms_api
pip freeze | grep tcms-api
deactivate
rm -rf .venv/
echo "..... PASS"