]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/setuptools-0.6c15dev.egg/setuptools/command/install.py
setup: install_requires argparse only if Python version is < 2.7
[tahoe-lafs/zfec.git] / zfec / setuptools-0.6c15dev.egg / setuptools / command / install.py
1 import setuptools, sys, glob
2 from distutils.command.install import install as _install
3 from distutils.errors import DistutilsArgError
4
5 class install(_install):
6     """Use easy_install to install the package, w/dependencies"""
7
8     user_options = _install.user_options + [
9         ('old-and-unmanageable', None, "Try not to use this!"),
10         ('single-version-externally-managed', None,
11             "used by system package builders to create 'flat' eggs"),
12     ]
13     boolean_options = _install.boolean_options + [
14         'old-and-unmanageable', 'single-version-externally-managed',
15     ]
16     new_commands = [
17         ('install_egg_info', lambda self: True),
18         ('install_scripts',  lambda self: True),
19     ]
20     _nc = dict(new_commands)
21     sub_commands = [
22         cmd for cmd in _install.sub_commands if cmd[0] not in _nc
23     ] + new_commands
24
25     def initialize_options(self):
26         _install.initialize_options(self)
27         self.old_and_unmanageable = None
28         self.single_version_externally_managed = None
29         self.no_compile = None  # make DISTUTILS_DEBUG work right!
30
31     def finalize_options(self):
32         _install.finalize_options(self)
33         if self.root:
34             self.single_version_externally_managed = True
35         elif self.single_version_externally_managed:
36             if not self.root and not self.record:
37                 raise DistutilsArgError(
38                     "You must specify --record or --root when building system"
39                     " packages"
40                 )
41
42     def handle_extra_path(self):
43         if self.root or self.single_version_externally_managed:
44             # explicit backward-compatibility mode, allow extra_path to work
45             return _install.handle_extra_path(self)
46
47         # Ignore extra_path when installing an egg (or being run by another
48         # command without --root or --single-version-externally-managed
49         self.path_file = None
50         self.extra_dirs = ''
51
52
53     def run(self):
54         # Explicit request for old-style install?  Just do it
55         if self.old_and_unmanageable or self.single_version_externally_managed:
56             return _install.run(self)
57
58         # Attempt to detect whether we were called from setup() or by another
59         # command.  If we were called by setup(), our caller will be the
60         # 'run_command' method in 'distutils.dist', and *its* caller will be
61         # the 'run_commands' method.  If we were called any other way, our
62         # immediate caller *might* be 'run_command', but it won't have been
63         # called by 'run_commands'.  This is slightly kludgy, but seems to
64         # work.
65         #
66         caller = sys._getframe(2)
67         caller_module = caller.f_globals.get('__name__','')
68         caller_name = caller.f_code.co_name
69
70         if caller_module != 'distutils.dist' or caller_name!='run_commands':
71             # We weren't called from the command line or setup(), so we
72             # should run in backward-compatibility mode to support bdist_*
73             # commands.
74             _install.run(self)
75         else:
76             self.do_egg_install()
77
78
79
80
81
82
83     def do_egg_install(self):
84
85         easy_install = self.distribution.get_command_class('easy_install')
86
87         cmd = easy_install(
88             self.distribution, args="x", root=self.root, record=self.record,
89         )
90         cmd.ensure_finalized()  # finalize before bdist_egg munges install cmd
91         cmd.always_copy_from = '.'  # make sure local-dir eggs get installed
92
93         # pick up setup-dir .egg files only: no .egg-info
94         cmd.package_index.scan(glob.glob('*.egg'))
95
96         self.run_command('bdist_egg')
97         args = [self.distribution.get_command_obj('bdist_egg').egg_output]
98
99         if setuptools.bootstrap_install_from:
100             # Bootstrap self-installation of setuptools
101             args.insert(0, setuptools.bootstrap_install_from)
102
103         cmd.args = args
104         cmd.run()
105         setuptools.bootstrap_install_from = None
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 #