update
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
from distutils.errors import DistutilsArgError
|
||||
import inspect
|
||||
from __future__ import annotations
|
||||
|
||||
import glob
|
||||
import inspect
|
||||
import platform
|
||||
import distutils.command.install as orig
|
||||
from collections.abc import Callable
|
||||
from typing import Any, ClassVar, cast
|
||||
|
||||
import setuptools
|
||||
|
||||
from ..dist import Distribution
|
||||
from ..warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
|
||||
from .bdist_egg import bdist_egg as bdist_egg_cls
|
||||
|
||||
import distutils.command.install as orig
|
||||
from distutils.errors import DistutilsArgError
|
||||
|
||||
# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
|
||||
# now. See https://github.com/pypa/setuptools/issues/199/
|
||||
@@ -15,6 +23,8 @@ _install = orig.install
|
||||
class install(orig.install):
|
||||
"""Use easy_install to install the package, w/dependencies"""
|
||||
|
||||
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
||||
|
||||
user_options = orig.install.user_options + [
|
||||
('old-and-unmanageable', None, "Try not to use this!"),
|
||||
(
|
||||
@@ -27,7 +37,9 @@ class install(orig.install):
|
||||
'old-and-unmanageable',
|
||||
'single-version-externally-managed',
|
||||
]
|
||||
new_commands = [
|
||||
# Type the same as distutils.command.install.install.sub_commands
|
||||
# Must keep the second tuple item potentially None due to invariance
|
||||
new_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] = [
|
||||
('install_egg_info', lambda self: True),
|
||||
('install_scripts', lambda self: True),
|
||||
]
|
||||
@@ -47,12 +59,12 @@ class install(orig.install):
|
||||
# and then add a due_date to this warning.
|
||||
)
|
||||
|
||||
orig.install.initialize_options(self)
|
||||
super().initialize_options()
|
||||
self.old_and_unmanageable = None
|
||||
self.single_version_externally_managed = None
|
||||
|
||||
def finalize_options(self):
|
||||
orig.install.finalize_options(self)
|
||||
super().finalize_options()
|
||||
if self.root:
|
||||
self.single_version_externally_managed = True
|
||||
elif self.single_version_externally_managed:
|
||||
@@ -71,18 +83,21 @@ class install(orig.install):
|
||||
# command without --root or --single-version-externally-managed
|
||||
self.path_file = None
|
||||
self.extra_dirs = ''
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
# Explicit request for old-style install? Just do it
|
||||
if self.old_and_unmanageable or self.single_version_externally_managed:
|
||||
return orig.install.run(self)
|
||||
return super().run()
|
||||
|
||||
if not self._called_from_setup(inspect.currentframe()):
|
||||
# Run in backward-compatibility mode to support bdist_* commands.
|
||||
orig.install.run(self)
|
||||
super().run()
|
||||
else:
|
||||
self.do_egg_install()
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _called_from_setup(run_frame):
|
||||
"""
|
||||
@@ -114,6 +129,8 @@ class install(orig.install):
|
||||
|
||||
return caller_module == 'distutils.dist' and info.function == 'run_commands'
|
||||
|
||||
return False
|
||||
|
||||
def do_egg_install(self):
|
||||
easy_install = self.distribution.get_command_class('easy_install')
|
||||
|
||||
@@ -130,7 +147,8 @@ class install(orig.install):
|
||||
cmd.package_index.scan(glob.glob('*.egg'))
|
||||
|
||||
self.run_command('bdist_egg')
|
||||
args = [self.distribution.get_command_obj('bdist_egg').egg_output]
|
||||
bdist_egg = cast(bdist_egg_cls, self.distribution.get_command_obj('bdist_egg'))
|
||||
args = [bdist_egg.egg_output]
|
||||
|
||||
if setuptools.bootstrap_install_from:
|
||||
# Bootstrap self-installation of setuptools
|
||||
|
||||
Reference in New Issue
Block a user