1
from distutils.errors import DistutilsArgError
6
import distutils.command.install as orig
10
# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
11
# now. See https://github.com/pypa/setuptools/issues/199/
12
_install = orig.install
15
class install(orig.install):
16
"""Use easy_install to install the package, w/dependencies"""
18
user_options = orig.install.user_options + [
19
('old-and-unmanageable', None, "Try not to use this!"),
20
('single-version-externally-managed', None,
21
"used by system package builders to create 'flat' eggs"),
23
boolean_options = orig.install.boolean_options + [
24
'old-and-unmanageable', 'single-version-externally-managed',
27
('install_egg_info', lambda self: True),
28
('install_scripts', lambda self: True),
30
_nc = dict(new_commands)
32
def initialize_options(self):
33
orig.install.initialize_options(self)
34
self.old_and_unmanageable = None
35
self.single_version_externally_managed = None
37
def finalize_options(self):
38
orig.install.finalize_options(self)
40
self.single_version_externally_managed = True
41
elif self.single_version_externally_managed:
42
if not self.root and not self.record:
43
raise DistutilsArgError(
44
"You must specify --record or --root when building system"
48
def handle_extra_path(self):
49
if self.root or self.single_version_externally_managed:
50
# explicit backward-compatibility mode, allow extra_path to work
51
return orig.install.handle_extra_path(self)
53
# Ignore extra_path when installing an egg (or being run by another
54
# command without --root or --single-version-externally-managed
59
# Explicit request for old-style install? Just do it
60
if self.old_and_unmanageable or self.single_version_externally_managed:
61
return orig.install.run(self)
63
if not self._called_from_setup(inspect.currentframe()):
64
# Run in backward-compatibility mode to support bdist_* commands.
65
orig.install.run(self)
70
def _called_from_setup(run_frame):
72
Attempt to detect whether run() was called from setup() or by another
73
command. If called by setup(), the parent caller will be the
74
'run_command' method in 'distutils.dist', and *its* caller will be
75
the 'run_commands' method. If called any other way, the
76
immediate caller *might* be 'run_command', but it won't have been
77
called by 'run_commands'. Return True in that case or if a call stack
78
is unavailable. Return False otherwise.
81
msg = "Call stack not available. bdist_* commands may fail."
83
if platform.python_implementation() == 'IronPython':
84
msg = "For best results, pass -X:Frames to enable call stack."
87
res = inspect.getouterframes(run_frame)[2]
89
info = inspect.getframeinfo(caller)
90
caller_module = caller.f_globals.get('__name__', '')
92
caller_module == 'distutils.dist'
93
and info.function == 'run_commands'
96
def do_egg_install(self):
98
easy_install = self.distribution.get_command_class('easy_install')
101
self.distribution, args="x", root=self.root, record=self.record,
103
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
104
cmd.always_copy_from = '.' # make sure local-dir eggs get installed
106
# pick up setup-dir .egg files only: no .egg-info
107
cmd.package_index.scan(glob.glob('*.egg'))
109
self.run_command('bdist_egg')
110
args = [self.distribution.get_command_obj('bdist_egg').egg_output]
112
if setuptools.bootstrap_install_from:
113
# Bootstrap self-installation of setuptools
114
args.insert(0, setuptools.bootstrap_install_from)
118
setuptools.bootstrap_install_from = None
121
# XXX Python 3.1 doesn't see _nc if this is inside the class
122
install.sub_commands = (
123
[cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc] +