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
):
35 "setup.py install is deprecated. "
36 "Use build and pip and other standards-based tools.",
37 setuptools
.SetuptoolsDeprecationWarning
,
40 orig
.install
.initialize_options(self
)
41 self
.old_and_unmanageable
= None
42 self
.single_version_externally_managed
= None
44 def finalize_options(self
):
45 orig
.install
.finalize_options(self
)
47 self
.single_version_externally_managed
= True
48 elif self
.single_version_externally_managed
:
49 if not self
.root
and not self
.record
:
50 raise DistutilsArgError(
51 "You must specify --record or --root when building system"
55 def handle_extra_path(self
):
56 if self
.root
or self
.single_version_externally_managed
:
57 # explicit backward-compatibility mode, allow extra_path to work
58 return orig
.install
.handle_extra_path(self
)
60 # Ignore extra_path when installing an egg (or being run by another
61 # command without --root or --single-version-externally-managed
66 # Explicit request for old-style install? Just do it
67 if self
.old_and_unmanageable
or self
.single_version_externally_managed
:
68 return orig
.install
.run(self
)
70 if not self
._called
_from
_setup
(inspect
.currentframe()):
71 # Run in backward-compatibility mode to support bdist_* commands.
72 orig
.install
.run(self
)
77 def _called_from_setup(run_frame
):
79 Attempt to detect whether run() was called from setup() or by another
80 command. If called by setup(), the parent caller will be the
81 'run_command' method in 'distutils.dist', and *its* caller will be
82 the 'run_commands' method. If called any other way, the
83 immediate caller *might* be 'run_command', but it won't have been
84 called by 'run_commands'. Return True in that case or if a call stack
85 is unavailable. Return False otherwise.
88 msg
= "Call stack not available. bdist_* commands may fail."
90 if platform
.python_implementation() == 'IronPython':
91 msg
= "For best results, pass -X:Frames to enable call stack."
95 frames
= inspect
.getouterframes(run_frame
)
96 for frame
in frames
[2:4]:
98 info
= inspect
.getframeinfo(caller
)
99 caller_module
= caller
.f_globals
.get('__name__', '')
101 if caller_module
== "setuptools.dist" and info
.function
== "run_command":
102 # Starting from v61.0.0 setuptools overwrites dist.run_command
106 caller_module
== 'distutils.dist'
107 and info
.function
== 'run_commands'
110 def do_egg_install(self
):
112 easy_install
= self
.distribution
.get_command_class('easy_install')
115 self
.distribution
, args
="x", root
=self
.root
, record
=self
.record
,
117 cmd
.ensure_finalized() # finalize before bdist_egg munges install cmd
118 cmd
.always_copy_from
= '.' # make sure local-dir eggs get installed
120 # pick up setup-dir .egg files only: no .egg-info
121 cmd
.package_index
.scan(glob
.glob('*.egg'))
123 self
.run_command('bdist_egg')
124 args
= [self
.distribution
.get_command_obj('bdist_egg').egg_output
]
126 if setuptools
.bootstrap_install_from
:
127 # Bootstrap self-installation of setuptools
128 args
.insert(0, setuptools
.bootstrap_install_from
)
131 cmd
.run(show_deprecation
=False)
132 setuptools
.bootstrap_install_from
= None
135 # XXX Python 3.1 doesn't see _nc if this is inside the class
136 install
.sub_commands
= (
137 [cmd
for cmd
in orig
.install
.sub_commands
if cmd
[0] not in install
._nc
] +