Re: Python postinstall scripts and compileall.py

2003-05-17 Thread Josselin Mouette
Le sam 17/05/2003 à 10:56, Sergio Talens-Oliag a écrit :
>   I looked at other python packages and I noticed that when the package
>   puts files on that directory the 'postinstall' scripts I've looked at
>   use the 'compileall.py' script over the
>   '/usr/lib/python$PV/site-packages' directory.

This is due to the fact dh_python is still a bit hackish. It is not a
performance issue as recursing through directories is very fast, but it
would be better to generate the file list at build time (which would
also allow the use of -X).

-- 
 .''`.   Josselin Mouette/\./\
: :' :   [EMAIL PROTECTED]
`. `'[EMAIL PROTECTED]
  `-  Debian GNU/Linux -- The power of freedom


signature.asc
Description: PGP signature


Python postinstall scripts and compileall.py

2003-05-17 Thread Sergio Talens-Oliag
  Hello all,

  Today I was looking at a bug report and while reviewing it I noticed
  that my postinstall script was wrong.
  
  The package installs 3 files in '/usr/lib/python$PV/site-packages',
  but after installation I wasn't compiling them.
  
  I looked at other python packages and I noticed that when the package
  puts files on that directory the 'postinstall' scripts I've looked at
  use the 'compileall.py' script over the
  '/usr/lib/python$PV/site-packages' directory.

  While that works O.K., it compiles everything under this directory and
  recurses until a depth of 10 subdirectories by default.

  In general it compiles nothing but the package files (each package
  should have compiled its sources), but I feel that this is not the
  right thing to do, IMHO every package should only take care of it's
  own files and don't touch others (unless it's really needed).

  I'm writting to the list to know what do you think about it.
  
  By the way, in my package I've modified the postinstall to compile
  only my files, the script is:

--*-- BEG: postinst --*--
#! /bin/sh -e
#
# postinst script for Debian python packages.
# Written 1998 by Gregor Hoffleit <[EMAIL PROTECTED]>.
# Modified 2001 by Matthias Klose <[EMAIL PROTECTED]>
# Modified 2003 by Sergio Talens-Oliag <[EMAIL PROTECTED]> for the
# python-htmltmpl package (only compile our .py files).

PACKAGE=`basename $0 .postinst`
PV=`dpkg --listfiles $PACKAGE | sed -n -e '/^\/usr\/lib\/python.*\//{
  s,/usr/lib/python\([0-9][0-9.]*\)/.*,\1,p
  q
}'`
PYTHON=python$PV
FILELIST=`dpkg --listfiles $PACKAGE | grep 
"^/usr/lib/python.*/site-packages/.*.py$"`

case "$1" in
  configure|abort-upgrade|abort-remove|abort-deconfigure)
for i in $FILELIST; do
  /usr/bin/$PYTHON -O -c "import py_compile; py_compile.compile('$i')"
  /usr/bin/$PYTHON -c "import py_compile; py_compile.compile('$i')"
done
  ;;

  *)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
  ;;
esac

#DEBHELPER#

exit 0
--*-- END: postinst --*--
 
-- 
Sergio Talens-Oliag <[EMAIL PROTECTED]>   
Key fingerprint = 29DF 544F  1BD9 548C  8F15 86EF  6770 052B  B8C1 FA69


pgpwbkGVzYf9A.pgp
Description: PGP signature