-
Notifications
You must be signed in to change notification settings - Fork 5
/
simplipy.sh
64 lines (38 loc) · 1.3 KB
/
simplipy.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
#!/bin/bash
if [[ $1 = '' ]]; then
echo "Missing arguments: simpliPy.sh <Python directory>
Example: simpliPy.sh ~/pyout"
exit 1
fi
echo "Original size is"
du -hs $1
read -p "Press [Enter] to simplipy " -n1 -s
cd $1
echo "Running unit-tests" #add -v for verbosity
bin/python -m unittest discover --start-directory lib/python2.7
echo "Are you happy with the results?"
read -p "Press [Enter] to continue or ctrl+Z to abort " -n1 -s
echo "Remove all unit test directories" #named 'test' or 'tests' ...
find . -type d -name "test*" -print0 | xargs -0 rm -rf
#compile all the .py into .pyc
#Alternatively `python -O -m compileall -f .` to produce .pyo
echo "Compling .py files"
python -m compileall -f .
echo "Removing all the .py files ..."
find . -type f -name "*.py" -delete
echo "Removing all the .pyo files ..."
#OR remove all the .pyc files, if you used -O earlier
#find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
echo "Removing duplicated binaries"
rm bin/python2.7 bin/python2
#remove the include/ directory if you don't plan calling Python
#from your C or C++ code
echo "Removing /include"
rm -rf include/
echo "Removing the man-pages"
rm -rf share/
echo "Done, the reduced size is:"
du -hs $1
echo "Running the simplipied version"
bin/python -c "import sys;print(sys.version)"