/[python-modules]/tools/find_python_dependencies.sh
ViewVC logotype

Contents of /tools/find_python_dependencies.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2566 - (show annotations) (download) (as text)
Mon Jun 18 19:48:32 2007 UTC (5 years, 11 months ago) by lool
File MIME type: application/x-sh
File size: 2205 byte(s)
* Spare an indentation level.
1 #!/bin/sh
2
3 # Copyright (C) 2007 Piotr Ożarowski <piotr@debian.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14
15 #
16 # PLEASE NOTE that this script will detect *installed* dependencies only
17 #
18 # TODO:
19 # * detect docstrings
20
21 if [ -z "$1" ]
22 then
23 echo "Please specify python module dir/file"
24 exit 1
25 fi
26
27 PYTHONPATH=$1
28 REGEXPR="[a-zA-Z_0-9\.]+"
29
30 # omit "from .* import .*" for now:
31 MODULES1=`grep -v \# -r $1 \
32 | grep -v "from .* import" | egrep -o "import $REGEXPR" \
33 | sort -u | cut -b 8-`
34
35 # "from .* import .*"
36 MODULES2=`grep -v \# -r $1 \
37 | grep "from .* import .*" | egrep -o "from $REGEXPR" \
38 | cut -b 6- | sort -u`
39 MODULES=`echo "$MODULES1"; echo "$MODULES2" | sort -u`
40
41 # example __file__ output: (remember while grepping)
42 # * pycentral:
43 # runtime: /usr/lib/python2.4/site-packages/chardet/__init__.pyc
44 # package: /usr/share/pycentral/python-chardet/site-packages/chardet/__init__.py
45 # * pysupport:
46 # runtime: /var/lib/python-support/python2.4/gtk-2.0/gtk/__init__.pyc
47 # package: /usr/share/python-support/python-gtk2/gtk-2.0/gtk/__init__.py
48 for i in $MODULES; do
49 case $i in
50 test*|os|os\.*|re|sys|logging|thread|sets|gettext) continue;;
51 an|and|the|error*) continue;;
52 esac
53 #echo " $i" # DEBUG
54 python -c "import $i as tmp; print tmp.__file__" 2>&1 \
55 | egrep -v "/usr/lib/python[2-9]\.[0-9]/$REGEXPR.py" \
56 | grep -v "Traceback" \
57 | grep -v 'File "<string>", line' \
58 | grep -v "ImportError: No module named logger" \
59 | grep -v "AttributeError:" \
60 | grep -v "ImportError: No module named auth" \
61 | grep -v "/usr/lib/python[0-9].[0-9]/lib-dynload/" \
62 | sed -e "s/\.pyc$/.py/" \
63 -e "s:.*/site-packages/:site-packages/:" \
64 -e "s:.*/python-support/python[0-9]\.[0-9]::" \
65 | xargs -I{} apt-file find {}
66 done

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5