@@ -45,46 +45,53 @@ update_ldcache() {
4545
4646compile ()
4747{
48+ sitelib=" usr/lib/python${pycompile_version} /site-packages"
49+
50+ # Starting with Python 3.5, compileall supports parallelism
51+ par=" "
52+ if [ " ${pycompile_version%% .* } " -gt 2 ]; then
53+ pycompile_minor=" ${pycompile_version#* .} "
54+ [ " ${pycompile_minor} " = " ${pycompile_version} " ] && pycompile_minor=" "
55+ if [ -z " ${pycompile_minor} " ] || ! [ " ${pycompile_minor} " -lt 5 ] > /dev/null 2>&1 ; then
56+ par=" -j0"
57+ fi
58+ fi
59+
4860 for f in ${pycompile_dirs} ; do
4961 echo " Byte-compiling python code in ${f} ..."
50- python${pycompile_version} -m compileall -f -q ./${f} && \
51- python${pycompile_version} -O -m compileall -f -q ./${f}
62+ python${pycompile_version} -m compileall ${par} -f -q ./${f} && \
63+ python${pycompile_version} -O -m compileall ${par} -f -q ./${f}
5264 done
65+
5366 for f in ${pycompile_module} ; do
5467 echo " Byte-compiling python${pycompile_version} code for module ${f} ..."
55- if [ -d " usr/lib/python${pycompile_version} /site-packages/${f} " ]; then
56- python${pycompile_version} -m compileall -f -q \
57- usr/lib/python${pycompile_version} /site-packages/${f} && \
58- python${pycompile_version} -O -m compileall -f -q \
59- usr/lib/python${pycompile_version} /site-packages/${f}
60- else
61- python${pycompile_version} -m compileall -f -q \
62- usr/lib/python${pycompile_version} /site-packages/${f} && \
63- python${pycompile_version} -O -m compileall -f -q \
64- usr/lib/python${pycompile_version} /site-packages/${f}
65- fi
68+ python${pycompile_version} -m compileall ${par} -f -q " ${sitelib} /${f} " && \
69+ python${pycompile_version} -O -m compileall ${par} -f -q " ${sitelib} /${f} "
6670 done
71+
6772 update_ldcache
6873}
6974
7075remove ()
7176{
77+ sitelib=" usr/lib/python${pycompile_version} /site-packages"
78+
7279 for f in ${pycompile_dirs} ; do
7380 echo " Removing byte-compiled python${pycompile_version} files in ${f} ..."
7481 find ./${f} -type f -name \* .py[co] -delete 2>&1 > /dev/null
7582 find ./${f} -type d -name __pycache__ -delete 2>&1 > /dev/null
7683 done
84+
7785 for f in ${pycompile_module} ; do
7886 echo " Removing byte-compiled python${pycompile_version} code for module ${f} ..."
79- if [ -d usr/lib/python${pycompile_version} /site-packages/${f} ]; then
80- find usr/lib/python${pycompile_version} /site-packages/${f} \
81- -type f -name \* .py[co] -delete 2>&1 > /dev/null
82- find usr/lib/python${pycompile_version} /site-packages/${f} \
83- -type d -name __pycache__ -delete 2>&1 > /dev/null
87+ if [ -d " ${sitelib} /${f} " ]; then
88+ find " ${sitelib} /${f} " -type f -name \* .py[co] -delete 2>&1 > /dev/null
89+ find " ${sitelib} /${f} " -type d -name __pycache__ -delete 2>&1 > /dev/null
8490 else
85- rm -f usr/lib/python ${pycompile_version} /site-packages /${f% .py} .py[co]
91+ rm -f " ${sitelib} " /${f% .py} .py[co]
8692 fi
8793 done
94+
8895 update_ldcache
8996}
9097
0 commit comments