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"
#
# Or if a module is stored in top-level site-packages directory:
#
# pycompile_module="foo.py"
#
# Arguments: $ACTION = [run/targets]
# $TARGET = [post-install/pre-remove]
# $PKGNAME
@ -40,10 +44,17 @@ compile()
done
for f in ${pycompile_module}; do
echo "Byte-compiling python code for module ${f}..."
if [ -d usr/lib/python${PYVER}/site-packages/${f} ]; then
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}
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
}
@ -55,8 +66,12 @@ remove()
done
for f in ${pycompile_module}; do
echo "Removing byte-compiled python code for module ${f}..."
if [ -d usr/lib/python${PYVER}/site-packages/${f} ]; then
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
}

View File

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