diff --git a/srcpkgs/xbps-triggers/files/pycompile b/srcpkgs/xbps-triggers/files/pycompile index 1e554421a9..aa73dd2fce 100755 --- a/srcpkgs/xbps-triggers/files/pycompile +++ b/srcpkgs/xbps-triggers/files/pycompile @@ -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}..." - 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} + 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}..." - find usr/lib/python${PYVER}/site-packages/${f} \ - -type f -name \*.py[co] -delete 2>&1 >/dev/null + 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 } diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index 6e0398eb14..f821b2c3f1 100644 --- a/srcpkgs/xbps-triggers/template +++ b/srcpkgs/xbps-triggers/template @@ -1,6 +1,6 @@ # Template file for 'xbps-triggers' pkgname=xbps-triggers -version=0.45 +version=0.46 revision=1 noarch=yes noextract=yes