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
12 __version__ = '0.6c16dev3'
14 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
18 bootstrap_install_from = None
20 def find_packages(where='.', exclude=()):
21 """Return a list all Python packages found within directory 'where'
23 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
24 will be converted to the appropriate local path syntax. 'exclude' is a
25 sequence of package names to exclude; '*' can be used as a wildcard in the
26 names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
30 stack=[(convert_path(where), '')]
32 where,prefix = stack.pop(0)
33 for name in os.listdir(where):
34 fn = os.path.join(where,name)
35 if ('.' not in name and os.path.isdir(fn) and
36 os.path.isfile(os.path.join(fn,'__init__.py'))
38 out.append(prefix+name); stack.append((fn,prefix+name+'.'))
39 for pat in list(exclude)+['ez_setup']:
40 from fnmatch import fnmatchcase
41 out = [item for item in out if not fnmatchcase(item,pat)]
44 setup = distutils.core.setup
46 _Command = _get_unpatched(_Command)
48 class Command(_Command):
49 __doc__ = _Command.__doc__
51 command_consumes_arguments = False
53 def __init__(self, dist, **kw):
54 # Add support for keyword arguments
55 _Command.__init__(self,dist)
56 for k,v in kw.items():
59 def reinitialize_command(self, command, reinit_subcommands=0, **kw):
60 cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
61 for k,v in kw.items():
62 setattr(cmd,k,v) # update command with keywords
66 distutils.core.Command = Command # we can't patch distutils.cmd, alas
68 def findall(dir = os.curdir):
69 """Find all files under 'dir' and return the list of full filenames
73 for base, dirs, files in os.walk(dir):
74 if base==os.curdir or base.startswith(os.curdir+os.sep):
77 files = [os.path.join(base, f) for f in files]
78 all_files.extend(filter(os.path.isfile, files))
81 import distutils.filelist
82 distutils.filelist.findall = findall # fix findall bug in distutils.
85 # sys.dont_write_bytecode was introduced in Python 2.6.
86 if ((hasattr(sys, "dont_write_bytecode") and sys.dont_write_bytecode) or
87 (not hasattr(sys, "dont_write_bytecode") and os.environ.get("PYTHONDONTWRITEBYTECODE"))):
88 _dont_write_bytecode = True
90 _dont_write_bytecode = False