From 733278535499d7b3b63def2cc0d7961d1e071062 Mon Sep 17 00:00:00 2001 From: pje Date: Sun, 7 Mar 2004 23:39:03 +0000 Subject: Added 'findPackages()' function to automatically list packages for setup. git-svn-id: svn://svn.eby-sarna.com/svnroot/wsgiref@237 571e12c6-e1fa-0310-aee7-ff1267fa46bd --- setuptools/__init__.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 172c77d..6fb8511 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -4,14 +4,31 @@ import distutils.core, setuptools.command from setuptools.dist import Distribution, Feature from setuptools.extension import Extension from distutils.core import Command +import os.path __all__ = [ - 'setup', 'Distribution', 'Feature', 'Command', 'Extension' + 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'findPackages' ] -def setup(**attrs): +def findPackages(where='.', prefix='', append=None): + """List all Python packages found within directory 'where'""" + + out = [] + if not append: + append = out.append + + for name in os.listdir(where): + fn = os.path.join(where,name) + if (os.path.isdir(fn) and + os.path.isfile(os.path.join(fn,'__init__.py')) + ): + append(prefix+name) + findPackages(fn,prefix+name+'.',append) + return out + +def setup(**attrs): """Do package setup This function takes the same arguments as 'distutils.core.setup()', except @@ -19,7 +36,6 @@ def setup(**attrs): that class' documentation for details on the new keyword arguments that it makes available via this function. """ - attrs.setdefault("distclass",Distribution) return distutils.core.setup(**attrs) -- cgit v1.2.1