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