1 """Extensions to the 'distutils' for large or complex distributions"""
2 from setuptools.extension import Extension, Library
3 from setuptools.dist import Distribution, Feature, _get_unpatched
4 import distutils.core, setuptools.command
5 from setuptools.depends import Require
6 from distutils.core import Command as _Command
7 from distutils.util import convert_path
10 __version__ = '0.6c15'
12 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
16 bootstrap_install_from = None
18 def find_packages(where='.', exclude=()):
19 """Return a list all Python packages found within directory 'where'
21 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
22 will be converted to the appropriate local path syntax. 'exclude' is a
23 sequence of package names to exclude; '*' can be used as a wildcard in the
24 names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
28 stack=[(convert_path(where), '')]
30 where,prefix = stack.pop(0)
31 for name in os.listdir(where):
32 fn = os.path.join(where,name)
33 if ('.' not in name and os.path.isdir(fn) and
34 os.path.isfile(os.path.join(fn,'__init__.py'))
36 out.append(prefix+name); stack.append((fn,prefix+name+'.'))
37 for pat in list(exclude)+['ez_setup']:
38 from fnmatch import fnmatchcase
39 out = [item for item in out if not fnmatchcase(item,pat)]
42 setup = distutils.core.setup
44 _Command = _get_unpatched(_Command)
46 class Command(_Command):
47 __doc__ = _Command.__doc__
49 command_consumes_arguments = False
51 def __init__(self, dist, **kw):
52 # Add support for keyword arguments
53 _Command.__init__(self,dist)
54 for k,v in kw.items():
57 def reinitialize_command(self, command, reinit_subcommands=0, **kw):
58 cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
59 for k,v in kw.items():
60 setattr(cmd,k,v) # update command with keywords
64 distutils.core.Command = Command # we can't patch distutils.cmd, alas
66 def findall(dir = os.curdir):
67 """Find all files under 'dir' and return the list of full filenames
71 for base, dirs, files in os.walk(dir):
72 if base==os.curdir or base.startswith(os.curdir+os.sep):
75 files = [os.path.join(base, f) for f in files]
76 all_files.extend(filter(os.path.isfile, files))
79 import distutils.filelist
80 distutils.filelist.findall = findall # fix findall bug in distutils.