1 import setuptools, sys, glob
2 from distutils.command.install import install as _install
3 from distutils.errors import DistutilsArgError
5 class install(_install):
6 """Use easy_install to install the package, w/dependencies"""
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"),
13 boolean_options = _install.boolean_options + [
14 'old-and-unmanageable', 'single-version-externally-managed',
17 ('install_egg_info', lambda self: True),
18 ('install_scripts', lambda self: True),
20 _nc = dict(new_commands)
22 cmd for cmd in _install.sub_commands if cmd[0] not in _nc
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!
31 def finalize_options(self):
32 _install.finalize_options(self)
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"
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)
47 # Ignore extra_path when installing an egg (or being run by another
48 # command without --root or --single-version-externally-managed
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)
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
66 caller = sys._getframe(2)
67 caller_module = caller.f_globals.get('__name__','')
68 caller_name = caller.f_code.co_name
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_*
83 def do_egg_install(self):
85 easy_install = self.distribution.get_command_class('easy_install')
88 self.distribution, args="x", root=self.root, record=self.record,
90 cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
91 cmd.always_copy_from = '.' # make sure local-dir eggs get installed
93 # pick up setup-dir .egg files only: no .egg-info
94 cmd.package_index.scan(glob.glob('*.egg'))
96 self.run_command('bdist_egg')
97 args = [self.distribution.get_command_obj('bdist_egg').egg_output]
99 if setuptools.bootstrap_install_from:
100 # Bootstrap self-installation of setuptools
101 args.insert(0, setuptools.bootstrap_install_from)
105 setuptools.bootstrap_install_from = None