Skip to content

Commit a1e956b

Browse files
committed
Revert "drop easy_install script and associated documentation"
This reverts commit 6e1838a.
1 parent 68dbb70 commit a1e956b

8 files changed

+1184
-21
lines changed

docs/easy_install.txt

+1,085
Large diffs are not rendered by default.

docs/index.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Documentation content:
2121
python3
2222
development
2323
roadmap
24+
Deprecated: Easy Install <easy_install>
2425
history

easy_install.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Run the EasyInstall command"""
2+
3+
if __name__ == '__main__':
4+
from setuptools.command.easy_install import main
5+
main()

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ classifiers =
5151
[options]
5252
zip_safe = True
5353
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
54+
py_modules = easy_install
5455
packages = find:
5556

5657
[options.packages.find]

setup.py

+19
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ def read_commands():
3131
return command_ns['__all__']
3232

3333

34+
def _gen_console_scripts():
35+
yield "easy_install = setuptools.command.easy_install:main"
36+
37+
# Gentoo distributions manage the python-version-specific scripts
38+
# themselves, so those platforms define an environment variable to
39+
# suppress the creation of the version-specific scripts.
40+
var_names = (
41+
'SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
42+
'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
43+
)
44+
if any(os.environ.get(var) not in (None, "", "0") for var in var_names):
45+
return
46+
tmpl = "easy_install-{shortver} = setuptools.command.easy_install:main"
47+
yield tmpl.format(shortver='{}.{}'.format(*sys.version_info))
48+
49+
3450
package_data = dict(
3551
setuptools=['script (dev).tmpl', 'script.tmpl', 'site-patch.py'],
3652
)
@@ -109,6 +125,9 @@ def pypi_link(pkg_filename):
109125
"depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
110126
"dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
111127
],
128+
"console_scripts": list(_gen_console_scripts()),
129+
"setuptools.installation":
130+
['eggsecutable = setuptools.command.easy_install:bootstrap'],
112131
},
113132
dependency_links=[
114133
pypi_link(

setuptools/command/easy_install.py

+54-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
__all__ = [
7575
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
76-
'get_exe_prefixes',
76+
'main', 'get_exe_prefixes',
7777
]
7878

7979

@@ -2289,6 +2289,59 @@ def current_umask():
22892289
return tmp
22902290

22912291

2292+
def bootstrap():
2293+
# This function is called when setuptools*.egg is run using /bin/sh
2294+
import setuptools
2295+
2296+
argv0 = os.path.dirname(setuptools.__path__[0])
2297+
sys.argv[0] = argv0
2298+
sys.argv.append(argv0)
2299+
main()
2300+
2301+
2302+
def main(argv=None, **kw):
2303+
from setuptools import setup
2304+
from setuptools.dist import Distribution
2305+
2306+
class DistributionWithoutHelpCommands(Distribution):
2307+
common_usage = ""
2308+
2309+
def _show_help(self, *args, **kw):
2310+
with _patch_usage():
2311+
Distribution._show_help(self, *args, **kw)
2312+
2313+
if argv is None:
2314+
argv = sys.argv[1:]
2315+
2316+
with _patch_usage():
2317+
setup(
2318+
script_args=['-q', 'easy_install', '-v'] + argv,
2319+
script_name=sys.argv[0] or 'easy_install',
2320+
distclass=DistributionWithoutHelpCommands,
2321+
**kw
2322+
)
2323+
2324+
2325+
@contextlib.contextmanager
2326+
def _patch_usage():
2327+
import distutils.core
2328+
USAGE = textwrap.dedent("""
2329+
usage: %(script)s [options] requirement_or_url ...
2330+
or: %(script)s --help
2331+
""").lstrip()
2332+
2333+
def gen_usage(script_name):
2334+
return USAGE % dict(
2335+
script=os.path.basename(script_name),
2336+
)
2337+
2338+
saved = distutils.core.gen_usage
2339+
distutils.core.gen_usage = gen_usage
2340+
try:
2341+
yield
2342+
finally:
2343+
distutils.core.gen_usage = saved
2344+
22922345
class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning):
22932346
"""Class for warning about deprecations in EasyInstall in SetupTools. Not ignored by default, unlike DeprecationWarning."""
22942347

setuptools/tests/test_easy_install.py

+16-18
Original file line numberDiff line numberDiff line change
@@ -467,24 +467,22 @@ def test_setup_requires_honors_fetch_params(self, mock_index, monkeypatch):
467467
"""
468468
monkeypatch.setenv(str('PIP_RETRIES'), str('0'))
469469
monkeypatch.setenv(str('PIP_TIMEOUT'), str('0'))
470-
monkeypatch.setenv(str('PIP_VERBOSE'), str('1'))
471-
# create an sdist that has a build-time dependency.
472-
with TestSetupRequires.create_sdist() as dist_file:
473-
with contexts.tempdir() as temp_dir:
474-
setup_py = os.path.join(temp_dir, 'setup.py')
475-
with open(setup_py, 'w') as fp:
476-
fp.write('__import__("setuptools").setup()')
477-
temp_install_dir = os.path.join(temp_dir, 'target')
478-
os.mkdir(temp_install_dir)
479-
with contexts.environment(PYTHONPATH=temp_install_dir):
480-
# attempt to install the dist. It should
481-
# fail because it doesn't exist.
482-
with pytest.raises(SystemExit):
483-
run_setup(setup_py, ['easy_install',
484-
'--exclude-scripts',
485-
'--index-url', mock_index.url,
486-
'--install-dir', temp_install_dir,
487-
dist_file])
470+
with contexts.quiet():
471+
# create an sdist that has a build-time dependency.
472+
with TestSetupRequires.create_sdist() as dist_file:
473+
with contexts.tempdir() as temp_install_dir:
474+
with contexts.environment(PYTHONPATH=temp_install_dir):
475+
ei_params = [
476+
'--index-url', mock_index.url,
477+
'--exclude-scripts',
478+
'--install-dir', temp_install_dir,
479+
dist_file,
480+
]
481+
with sandbox.save_argv(['easy_install']):
482+
# attempt to install the dist. It should
483+
# fail because it doesn't exist.
484+
with pytest.raises(SystemExit):
485+
easy_install_pkg.main(ei_params)
488486
# there should have been one requests to the server
489487
assert [r.path for r in mock_index.requests] == ['/does-not-exist/']
490488

setuptools/tests/test_namespaces.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ def test_pkg_resources_import(self, tmpdir):
6464
target.mkdir()
6565
install_cmd = [
6666
sys.executable,
67-
'-m', 'pip.__main__', 'install',
68-
'-t', str(target), str(pkg),
67+
'-m', 'easy_install',
68+
'-d', str(target),
69+
str(pkg),
6970
]
7071
with test.test.paths_on_pythonpath([str(target)]):
7172
subprocess.check_call(install_cmd)

0 commit comments

Comments
 (0)