xbps-triggers: added support for additional python versions in pycompile.

This commit is contained in:
Juan RP 2014-06-18 11:25:35 +02:00
parent baa8845c91
commit 45d79b96ea
2 changed files with 19 additions and 18 deletions

View File

@ -18,6 +18,10 @@
#
# pycompile_module="foo.py"
#
# Additionally another var can be used to specify the target python version:
#
# pycompile_version="3.4"
#
# Arguments: $ACTION = [run/targets]
# $TARGET = [post-install/pre-remove]
# $PKGNAME
@ -30,30 +34,27 @@ PKGNAME="$3"
VERSION="$4"
UPDATE="$5"
# Current python version used in XBPS.
PYVER="2.7"
export PATH="$PATH:/usr/local/bin"
compile()
{
for f in ${pycompile_dirs}; do
echo "Byte-compiling python code in ${f}..."
python -m compileall -f -q ${f} && \
python -O -m compileall -f -q ${f}
python${pycompile_version} -m compileall -f -q ${f} && \
python${pycompile_version} -O -m compileall -f -q ${f}
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
echo "Byte-compiling python${pycompile_version} code for module ${f}..."
if [ -d usr/lib/python${pycompile_version}/site-packages/${f} ]; then
python -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f} && \
usr/lib/python${pycompile_version}/site-packages/${f} && \
python -O -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f}
usr/lib/python${pycompile_version}/site-packages/${f}
else
python -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f} && \
usr/lib/python${pycompile_version}/site-packages/${f} && \
python -O -m compileall -f -q \
usr/lib/python${PYVER}/site-packages/${f}
usr/lib/python${pycompile_version}/site-packages/${f}
fi
done
}
@ -61,16 +62,16 @@ compile()
remove()
{
for f in ${pycompile_dirs}; do
echo "Removing byte-compiled python files in ${f}..."
echo "Removing byte-compiled python${pycompile_version} files in ${f}..."
find ${f} -type f -name \*.py[co] -delete 2>&1 >/dev/null
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} \
echo "Removing byte-compiled python${pycompile_version} code for module ${f}..."
if [ -d usr/lib/python${pycompile_version}/site-packages/${f} ]; then
find usr/lib/python${pycompile_version}/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]
rm -f usr/lib/python${pycompile_version}/site-packages/${f%.py}.py[co]
fi
done
}
@ -80,7 +81,7 @@ targets)
echo "post-install pre-remove"
;;
run)
[ ! -x usr/bin/python ] && exit 0
[ ! -x usr/bin/python${pycompile_version} ] && exit 0
[ -z "${pycompile_dirs}" -a -z "${pycompile_module}" ] && exit 0
case "$TARGET" in

View File

@ -1,6 +1,6 @@
# Template file for 'xbps-triggers'
pkgname=xbps-triggers
version=0.77
version=0.78
revision=1
noarch=yes
bootstrap=yes