Project

General

Profile

Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / distribute-0.6.19-py2.7.egg / setuptools / command / install.py @ 1a305335

History | View | Annotate | Download (3.97 KB)

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

    
22
    def initialize_options(self):
23
        _install.initialize_options(self)
24
        self.old_and_unmanageable = None
25
        self.single_version_externally_managed = None
26
        self.no_compile = None  # make DISTUTILS_DEBUG work right!
27

    
28
    def finalize_options(self):
29
        _install.finalize_options(self)
30
        if self.root:
31
            self.single_version_externally_managed = True
32
        elif self.single_version_externally_managed:
33
            if not self.root and not self.record:
34
                raise DistutilsArgError(
35
                    "You must specify --record or --root when building system"
36
                    " packages"
37
                )
38

    
39
    def handle_extra_path(self):
40
        if self.root or self.single_version_externally_managed:
41
            # explicit backward-compatibility mode, allow extra_path to work
42
            return _install.handle_extra_path(self)
43

    
44
        # Ignore extra_path when installing an egg (or being run by another
45
        # command without --root or --single-version-externally-managed
46
        self.path_file = None
47
        self.extra_dirs = ''
48

    
49

    
50
    def run(self):
51
        # Explicit request for old-style install?  Just do it
52
        if self.old_and_unmanageable or self.single_version_externally_managed:
53
            return _install.run(self)
54

    
55
        # Attempt to detect whether we were called from setup() or by another
56
        # command.  If we were called by setup(), our caller will be the
57
        # 'run_command' method in 'distutils.dist', and *its* caller will be
58
        # the 'run_commands' method.  If we were called any other way, our
59
        # immediate caller *might* be 'run_command', but it won't have been
60
        # called by 'run_commands'.  This is slightly kludgy, but seems to
61
        # work.
62
        #
63
        caller = sys._getframe(2)
64
        caller_module = caller.f_globals.get('__name__','')
65
        caller_name = caller.f_code.co_name
66

    
67
        if caller_module != 'distutils.dist' or caller_name!='run_commands':
68
            # We weren't called from the command line or setup(), so we
69
            # should run in backward-compatibility mode to support bdist_*
70
            # commands.
71
            _install.run(self)
72
        else:
73
            self.do_egg_install()
74

    
75

    
76

    
77

    
78

    
79

    
80
    def do_egg_install(self):
81

    
82
        easy_install = self.distribution.get_command_class('easy_install')
83

    
84
        cmd = easy_install(
85
            self.distribution, args="x", root=self.root, record=self.record,
86
        )
87
        cmd.ensure_finalized()  # finalize before bdist_egg munges install cmd
88
        cmd.always_copy_from = '.'  # make sure local-dir eggs get installed
89

    
90
        # pick up setup-dir .egg files only: no .egg-info
91
        cmd.package_index.scan(glob.glob('*.egg'))
92

    
93
        self.run_command('bdist_egg')
94
        args = [self.distribution.get_command_obj('bdist_egg').egg_output]
95

    
96
        if setuptools.bootstrap_install_from:
97
            # Bootstrap self-installation of setuptools
98
            args.insert(0, setuptools.bootstrap_install_from)
99

    
100
        cmd.args = args
101
        cmd.run()
102
        setuptools.bootstrap_install_from = None
103

    
104
# XXX Python 3.1 doesn't see _nc if this is inside the class
105
install.sub_commands = [
106
        cmd for cmd in _install.sub_commands if cmd[0] not in install._nc
107
    ] + install.new_commands
108

    
109

    
110

    
111

    
112

    
113

    
114

    
115

    
116

    
117

    
118

    
119

    
120

    
121

    
122

    
123

    
124
#