xbps-triggers: pycompile: support modules at top-level site-packages dir.

This commit is contained in:
Juan RP 2012-09-19 11:38:48 +02:00
parent cb60ca1e43
commit 08652c703a
2 changed files with 22 additions and 7 deletions

View file

@ -14,6 +14,10 @@
# #
# pycompile_module="blah foo" # pycompile_module="blah foo"
# #
# Or if a module is stored in top-level site-packages directory:
#
# pycompile_module="foo.py"
#
# Arguments: $ACTION = [run/targets] # Arguments: $ACTION = [run/targets]
# $TARGET = [post-install/pre-remove] # $TARGET = [post-install/pre-remove]
# $PKGNAME # $PKGNAME
@ -40,10 +44,17 @@ compile()
done done
for f in ${pycompile_module}; do for f in ${pycompile_module}; do
echo "Byte-compiling python code for module ${f}..." echo "Byte-compiling python code for module ${f}..."
python -m compileall -f -q \ if [ -d usr/lib/python${PYVER}/site-packages/${f} ]; then
usr/lib/python${PYVER}/site-packages/${f} && \ python -m compileall -f -q \
python -O -m compileall -f -q \ usr/lib/python${PYVER}/site-packages/${f} && \
usr/lib/python${PYVER}/site-packages/${f} python -O -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f}
else
python -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f} && \
python -O -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f}
fi
done done
} }
@ -55,8 +66,12 @@ remove()
done done
for f in ${pycompile_module}; do for f in ${pycompile_module}; do
echo "Removing byte-compiled python code for module ${f}..." echo "Removing byte-compiled python code for module ${f}..."
find usr/lib/python${PYVER}/site-packages/${f} \ if [ -d usr/lib/python${PYVER}/site-packages/${f} ]; then
-type f -name \*.py[co] -delete 2>&1 >/dev/null find usr/lib/python${PYVER}/site-packages/${f} \
-type f -name \*.py[co] -delete 2>&1 >/dev/null
else
rm -f usr/lib/python${PYVER}/site-packages/${f%.py}.py[co]
fi
done done
} }

View file

@ -1,6 +1,6 @@
# Template file for 'xbps-triggers' # Template file for 'xbps-triggers'
pkgname=xbps-triggers pkgname=xbps-triggers
version=0.45 version=0.46
revision=1 revision=1
noarch=yes noarch=yes
noextract=yes noextract=yes