[Zope3-checkins] CVS: Zope3/utilities - finddeps.py:1.9

Fred L. Drake, Jr. fred at zope.com
Thu Mar 11 15:23:36 EST 2004


Update of /cvs-repository/Zope3/utilities
In directory cvs.zope.org:/tmp/cvs-serv19263

Modified Files:
	finddeps.py 
Log Message:
change the way we determine whether a module is in the standard
library


=== Zope3/utilities/finddeps.py 1.8 => 1.9 ===
--- Zope3/utilities/finddeps.py:1.8	Thu Mar 11 14:43:59 2004
+++ Zope3/utilities/finddeps.py	Thu Mar 11 15:23:35 2004
@@ -151,7 +151,17 @@
 
 
 def filterStandardModules(deps):
-    """Try to remove modules from the standard Python library."""
+    """Try to remove modules from the standard Python library.
+
+    Modules are considered part of the standard library if their
+    __file__ is located in the tree rooted at the parent of the
+    site-packages directory, but not in the sub-tree in site-packages.
+    """
+    from distutils import sysconfig
+    site_packages = sysconfig.get_python_lib()
+    standard_lib = os.path.dirname(site_packages)
+    site_packages = os.path.join(site_packages, "")
+    standard_lib = os.path.join(standard_lib, "")
     filteredDeps = []
     for dep in deps:
         try:
@@ -161,9 +171,10 @@
         # built-ins (like sys) do not have a file associated
         if not hasattr(module, '__file__'):
             continue
-        dir = os.path.dirname(module.__file__)
-        if dir.startswith(ZOPESRC):
-            filteredDeps.append(dep)
+        starts = module.__file__.startswith
+        if starts(standard_lib) and not starts(site_packages):
+            continue
+        filteredDeps.append(dep)
     return filteredDeps
 
 




More information about the Zope3-Checkins mailing list