aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-11-23 14:16:53 -0500
committerGitHub <noreply@github.com>2019-11-23 14:16:53 -0500
commite44d9bcd4288bed098f09b24c3667ef02621699d (patch)
tree9d47f5b97523580de6fa2dc449f6ca630226503b /setuptools/command/easy_install.py
parente31c9f0c37e545022f5c0cdacd28ab4432b1a6df (diff)
parent4188aba5265e9b7145b1c5ed10c8e0ae769f70b4 (diff)
downloadexternal_python_setuptools-e44d9bcd4288bed098f09b24c3667ef02621699d.tar.gz
external_python_setuptools-e44d9bcd4288bed098f09b24c3667ef02621699d.tar.bz2
external_python_setuptools-e44d9bcd4288bed098f09b24c3667ef02621699d.zip
Merge pull request #1909 from benoit-pierre/resurrect_easy_install_script
Revert "drop easy_install script and associated documentation"
Diffstat (limited to 'setuptools/command/easy_install.py')
-rw-r--r--setuptools/command/easy_install.py55
1 files changed, 54 insertions, 1 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index d273bc10..09066f8c 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -73,7 +73,7 @@ warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
__all__ = [
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
- 'get_exe_prefixes',
+ 'main', 'get_exe_prefixes',
]
@@ -2289,6 +2289,59 @@ def current_umask():
return tmp
+def bootstrap():
+ # This function is called when setuptools*.egg is run using /bin/sh
+ import setuptools
+
+ argv0 = os.path.dirname(setuptools.__path__[0])
+ sys.argv[0] = argv0
+ sys.argv.append(argv0)
+ main()
+
+
+def main(argv=None, **kw):
+ from setuptools import setup
+ from setuptools.dist import Distribution
+
+ class DistributionWithoutHelpCommands(Distribution):
+ common_usage = ""
+
+ def _show_help(self, *args, **kw):
+ with _patch_usage():
+ Distribution._show_help(self, *args, **kw)
+
+ if argv is None:
+ argv = sys.argv[1:]
+
+ with _patch_usage():
+ setup(
+ script_args=['-q', 'easy_install', '-v'] + argv,
+ script_name=sys.argv[0] or 'easy_install',
+ distclass=DistributionWithoutHelpCommands,
+ **kw
+ )
+
+
+@contextlib.contextmanager
+def _patch_usage():
+ import distutils.core
+ USAGE = textwrap.dedent("""
+ usage: %(script)s [options] requirement_or_url ...
+ or: %(script)s --help
+ """).lstrip()
+
+ def gen_usage(script_name):
+ return USAGE % dict(
+ script=os.path.basename(script_name),
+ )
+
+ saved = distutils.core.gen_usage
+ distutils.core.gen_usage = gen_usage
+ try:
+ yield
+ finally:
+ distutils.core.gen_usage = saved
+
class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning):
"""Class for warning about deprecations in EasyInstall in SetupTools. Not ignored by default, unlike DeprecationWarning."""