root / env / lib / python2.7 / site-packages / distribute-0.6.19-py2.7.egg / setuptools / __init__.py @ 1a305335
History | View | Annotate | Download (3.66 KB)
1 | 1a305335 | officers | """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 |
||
9 | import sys |
||
10 | |||
11 | __version__ = '0.6'
|
||
12 | __all__ = [ |
||
13 | 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', |
||
14 | 'find_packages'
|
||
15 | ] |
||
16 | |||
17 | # This marker is used to simplify the process that checks is the
|
||
18 | # setuptools package was installed by the Setuptools project
|
||
19 | # or by the Distribute project, in case Setuptools creates
|
||
20 | # a distribution with the same version.
|
||
21 | #
|
||
22 | # The distribute_setup script for instance, will check if this
|
||
23 | # attribute is present to decide whether to reinstall the package
|
||
24 | # or not.
|
||
25 | _distribute = True
|
||
26 | |||
27 | bootstrap_install_from = None
|
||
28 | |||
29 | # If we run 2to3 on .py files, should we also convert docstrings?
|
||
30 | # Default: yes; assume that we can detect doctests reliably
|
||
31 | run_2to3_on_doctests = True
|
||
32 | # Standard package names for fixer packages
|
||
33 | lib2to3_fixer_packages = ['lib2to3.fixes']
|
||
34 | |||
35 | def find_packages(where='.', exclude=()): |
||
36 | """Return a list all Python packages found within directory 'where'
|
||
37 |
|
||
38 | 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
|
||
39 | will be converted to the appropriate local path syntax. 'exclude' is a
|
||
40 | sequence of package names to exclude; '*' can be used as a wildcard in the
|
||
41 | names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
|
||
42 | 'foo' itself).
|
||
43 | """
|
||
44 | out = [] |
||
45 | stack=[(convert_path(where), '')]
|
||
46 | while stack:
|
||
47 | where,prefix = stack.pop(0)
|
||
48 | for name in os.listdir(where): |
||
49 | fn = os.path.join(where,name) |
||
50 | if ('.' not in name and os.path.isdir(fn) and |
||
51 | os.path.isfile(os.path.join(fn,'__init__.py'))
|
||
52 | ): |
||
53 | out.append(prefix+name); stack.append((fn,prefix+name+'.'))
|
||
54 | for pat in list(exclude)+['ez_setup', 'distribute_setup']: |
||
55 | from fnmatch import fnmatchcase |
||
56 | out = [item for item in out if not fnmatchcase(item,pat)] |
||
57 | return out
|
||
58 | |||
59 | setup = distutils.core.setup |
||
60 | |||
61 | _Command = _get_unpatched(_Command) |
||
62 | |||
63 | class Command(_Command): |
||
64 | __doc__ = _Command.__doc__ |
||
65 | |||
66 | command_consumes_arguments = False
|
||
67 | |||
68 | def __init__(self, dist, **kw): |
||
69 | # Add support for keyword arguments
|
||
70 | _Command.__init__(self,dist)
|
||
71 | for k,v in kw.items(): |
||
72 | setattr(self,k,v) |
||
73 | |||
74 | def reinitialize_command(self, command, reinit_subcommands=0, **kw): |
||
75 | cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
|
||
76 | for k,v in kw.items(): |
||
77 | setattr(cmd,k,v) # update command with keywords |
||
78 | return cmd
|
||
79 | |||
80 | import distutils.core |
||
81 | distutils.core.Command = Command # we can't patch distutils.cmd, alas
|
||
82 | |||
83 | def findall(dir = os.curdir): |
||
84 | """Find all files under 'dir' and return the list of full filenames
|
||
85 | (relative to 'dir').
|
||
86 | """
|
||
87 | all_files = [] |
||
88 | for base, dirs, files in os.walk(dir): |
||
89 | if base==os.curdir or base.startswith(os.curdir+os.sep): |
||
90 | base = base[2:]
|
||
91 | if base:
|
||
92 | files = [os.path.join(base, f) for f in files] |
||
93 | all_files.extend(filter(os.path.isfile, files))
|
||
94 | return all_files
|
||
95 | |||
96 | import distutils.filelist |
||
97 | distutils.filelist.findall = findall # fix findall bug in distutils.
|
||
98 | |||
99 | # sys.dont_write_bytecode was introduced in Python 2.6.
|
||
100 | if ((hasattr(sys, "dont_write_bytecode") and sys.dont_write_bytecode) or |
||
101 | (not hasattr(sys, "dont_write_bytecode") and os.environ.get("PYTHONDONTWRITEBYTECODE"))): |
||
102 | _dont_write_bytecode = True
|
||
103 | else:
|
||
104 | _dont_write_bytecode = False |