[Python-checkins] python/nondist/sandbox/setuptools/setuptools __init__.py, 1.14, 1.15

pje@users.sourceforge.net pje at users.sourceforge.net
Sat Jul 9 06:24:40 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32506/setuptools

Modified Files:
	__init__.py 
Log Message:
Added ``exclude=patternlist`` option to ``setuptools.find_packages()``


Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/__init__.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- __init__.py	8 Jul 2005 15:52:05 -0000	1.14
+++ __init__.py	9 Jul 2005 04:24:38 -0000	1.15
@@ -1,5 +1,4 @@
 """Extensions to the 'distutils' for large or complex distributions"""
-
 import distutils.core, setuptools.command
 from setuptools.dist import Distribution, Feature
 from setuptools.extension import Extension
@@ -9,7 +8,6 @@
 import os.path
 
 __version__ = '0.5a8'
-
 __all__ = [
     'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
     'find_packages'
@@ -17,16 +15,17 @@
 
 bootstrap_install_from = None
 
-def find_packages(where='.'):
+def find_packages(where='.', exclude=()):
     """Return a list all Python packages found within directory 'where'
 
     'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
-    will be converted to the appropriate local path syntax.
+    will be converted to the appropriate local path syntax.  'exclude' is a
+    sequence of package names to exclude; '*' can be used as a wildcard in the
+    names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
+    'foo' itself).
     """
-
     out = []
     stack=[(convert_path(where), '')]
-
     while stack:
         where,prefix = stack.pop(0)
         for name in os.listdir(where):
@@ -35,10 +34,11 @@
                 os.path.isfile(os.path.join(fn,'__init__.py'))
             ):
                 out.append(prefix+name); stack.append((fn,prefix+name+'.'))
+    for pat in exclude:
+        from fnmatch import fnmatchcase
+        out = [item for item in out if not fnmatchcase(item,pat)]
     return out
 
-
-
 def setup(**attrs):
     """Do package setup
 



More information about the Python-checkins mailing list