]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/setuptools-0.6c15dev.egg/setuptools/__init__.py
setup: install_requires argparse only if Python version is < 2.7
[tahoe-lafs/zfec.git] / zfec / setuptools-0.6c15dev.egg / setuptools / __init__.py
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
8 import os.path
9
10 __version__ = '0.6c15'
11 __all__ = [
12     'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
13     'find_packages'
14 ]
15
16 bootstrap_install_from = None
17
18 def find_packages(where='.', exclude=()):
19     """Return a list all Python packages found within directory 'where'
20
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
25     'foo' itself).
26     """
27     out = []
28     stack=[(convert_path(where), '')]
29     while stack:
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'))
35             ):
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)]
40     return out
41
42 setup = distutils.core.setup
43
44 _Command = _get_unpatched(_Command)
45
46 class Command(_Command):
47     __doc__ = _Command.__doc__
48
49     command_consumes_arguments = False
50
51     def __init__(self, dist, **kw):
52         # Add support for keyword arguments
53         _Command.__init__(self,dist)
54         for k,v in kw.items():
55             setattr(self,k,v)
56
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
61         return cmd
62
63 import distutils.core
64 distutils.core.Command = Command    # we can't patch distutils.cmd, alas
65
66 def findall(dir = os.curdir):
67     """Find all files under 'dir' and return the list of full filenames
68     (relative to 'dir').
69     """
70     all_files = []
71     for base, dirs, files in os.walk(dir):
72         if base==os.curdir or base.startswith(os.curdir+os.sep):
73             base = base[2:]
74         if base:
75             files = [os.path.join(base, f) for f in files]
76         all_files.extend(filter(os.path.isfile, files))
77     return all_files
78
79 import distutils.filelist
80 distutils.filelist.findall = findall    # fix findall bug in distutils.
81
82