Script for locating python modules

Jack Jansen (Jack.Jansen@cwi.nl)
Mon, 31 Jan 1994 14:03:21 +0100

With the advent of python understanding .pyc files without the
corresponding .py files I've had to hunt for 'orphaned' .pyc files so
often that I've written a shell script pwhich which runs down the
PYTHONPATH and prints all occurrences of a module. Yes, I know, it
should have been written in python, but here it is anyway:
--------------------
#!/bin/sh
modules=$*
oldifs=$IFS
IFS=$IFS:
dftpythonpath=`python -c 'import sys
for i in sys.path: print i
'`
: ${PYTHONPATH=$dftpythonpath}
set $PYTHONPATH
for m in $modules; do
for p in $*; do
for ext in py pyc o so; do
#echo 'look for' $p/$m.$ext
if [ -f $p/$m.$ext ]; then
echo $m': '$p/$m.$ext
fi
done
done
done

--
Jack Jansen        | If I can't dance I don't want to be part of
Jack.Jansen@cwi.nl | your revolution             -- Emma Goldman
uunet!cwi.nl!jack    G=Jack;S=Jansen;O=cwi;PRMD=surf;ADMD=400net;C=nl