summaryrefslogtreecommitdiffstats
path: root/dracut/python-deps
diff options
context:
space:
mode:
authorWill Woods <wwoods@redhat.com>2012-03-02 17:56:28 -0500
committerWill Woods <wwoods@redhat.com>2012-03-02 17:56:28 -0500
commit0539a9f9ca674807bdd39f15d7cf19394b398c3d (patch)
treeff71086d1dfac44e90e210c5af9cf081d4ffa0f6 /dracut/python-deps
parent44415f5b982440f0f47e0b4a62f228180f974206 (diff)
downloadanaconda-0539a9f9ca674807bdd39f15d7cf19394b398c3d.tar.gz
anaconda-0539a9f9ca674807bdd39f15d7cf19394b398c3d.tar.xz
anaconda-0539a9f9ca674807bdd39f15d7cf19394b398c3d.zip
python-deps: cleanups/comments
Diffstat (limited to 'dracut/python-deps')
-rwxr-xr-xdracut/python-deps23
1 files changed, 15 insertions, 8 deletions
diff --git a/dracut/python-deps b/dracut/python-deps
index 46abbcf8d..be51e7807 100755
--- a/dracut/python-deps
+++ b/dracut/python-deps
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# python-deps - find the dependencies of a given python script.
import os, sys
from modulefinder import ModuleFinder
@@ -7,6 +8,7 @@ from distutils.sysconfig import *
sitedir = get_python_lib()
libdir = get_config_var('LIBDEST')
+# A couple helper functions...
def moduledir(pyfile):
'''Given a python file, return the module dir it belongs to, or None.'''
for topdir in sitedir, libdir:
@@ -23,27 +25,32 @@ def pyfiles(moddir):
if f.endswith(".py"):
yield os.path.join(curdir, f)
+# OK. Use modulefinder to find all the modules etc. this script uses!
-# use modulefinder to find all the modules etc. this script uses!
-mods = []
-deps = []
finder = ModuleFinder()
finder.run_script(sys.argv[1]) # parse the script
+
+mods = []
+deps = []
+
for name, mod in finder.modules.iteritems():
- if not mod.__file__: # builtin - skip it
+ if not mod.__file__: # this module is builtin, so we can skip it
continue
+
if mod.__file__ not in deps: # grab the file itself
deps.append(mod.__file__)
- moddir = moduledir(mod.__file__)
- if moddir and moddir not in mods: # if it's part of a module..
- deps += list(pyfiles(moddir)) # ..get the whole module
+
+ moddir = moduledir(mod.__file__) # if it's part of a module...
+ if moddir and moddir not in mods: #
+ deps += list(pyfiles(moddir)) # ...get the whole module
mods.append(moddir)
-# Start with some basic bits that the python install itself needs
+# Include some bits that the python install itself needs
print get_makefile_filename()
print get_config_h_filename()
print os.path.join(libdir,'site.py')
print os.path.join(libdir,'sysconfig.py')
+# And print the list of deps.
for d in deps:
print d