Remove the deprecated --download option to install

This commit is contained in:
Donald Stufft 2017-03-19 21:26:36 -04:00
parent bb41490225
commit e6bfa12403
5 changed files with 33 additions and 252 deletions

1
news/2643.removal Normal file
View File

@ -0,0 +1 @@
Removed the deprecated ``--download`` option to ``pip install``.

View File

@ -5,7 +5,6 @@ import operator
import os
import tempfile
import shutil
import warnings
try:
import wheel
except ImportError:
@ -20,7 +19,6 @@ from pip.exceptions import (
from pip import cmdoptions
from pip.utils import ensure_dir, get_installed_version
from pip.utils.build import BuildDirectory
from pip.utils.deprecation import RemovedInPip10Warning
from pip.utils.filesystem import check_path_owner
from pip.wheel import WheelCache, WheelBuilder
@ -95,14 +93,6 @@ class InstallCommand(RequirementCommand):
help="Installation prefix where lib, bin and other top-level "
"folders are placed")
cmd_opts.add_option(
'-d', '--download', '--download-dir', '--download-directory',
dest='download_dir',
metavar='dir',
default=None,
help=("Download packages into <dir> instead of installing them, "
"regardless of what's already installed."),
)
cmd_opts.add_option(cmdoptions.build_dir())
cmd_opts.add_option(cmdoptions.src())
@ -183,15 +173,6 @@ class InstallCommand(RequirementCommand):
cmdoptions.resolve_wheel_no_use_binary(options)
cmdoptions.check_install_build_global(options)
if options.download_dir:
warnings.warn(
"pip install --download has been deprecated and will be "
"removed in the future. Pip now has a download command that "
"should be used instead.",
RemovedInPip10Warning,
)
options.ignore_installed = True
if options.build_dir:
options.build_dir = os.path.abspath(options.build_dir)
@ -247,7 +228,6 @@ class InstallCommand(RequirementCommand):
requirement_set = RequirementSet(
build_dir=build_dir,
src_dir=options.src_dir,
download_dir=options.download_dir,
upgrade=options.upgrade,
upgrade_strategy=options.upgrade_strategy,
ignore_installed=options.ignore_installed,
@ -270,8 +250,7 @@ class InstallCommand(RequirementCommand):
)
try:
if (options.download_dir or not wheel or not
options.cache_dir):
if (not wheel or not options.cache_dir):
# on -d don't do complex things like building
# wheels, and don't try to build wheels when wheel is
# not installed.
@ -288,48 +267,38 @@ class InstallCommand(RequirementCommand):
# installed from the sdist/vcs whatever.
wb.build(autobuilding=True)
if not options.download_dir:
requirement_set.install(
install_options,
global_options,
root=options.root_path,
prefix=options.prefix_path,
)
requirement_set.install(
install_options,
global_options,
root=options.root_path,
prefix=options.prefix_path,
)
possible_lib_locations = get_lib_location_guesses(
user=options.use_user_site,
home=temp_target_dir,
root=options.root_path,
prefix=options.prefix_path,
isolated=options.isolated_mode,
)
reqs = sorted(
requirement_set.successfully_installed,
key=operator.attrgetter('name'))
items = []
for req in reqs:
item = req.name
try:
installed_version = get_installed_version(
req.name, possible_lib_locations
)
if installed_version:
item += '-' + installed_version
except Exception:
pass
items.append(item)
installed = ' '.join(items)
if installed:
logger.info('Successfully installed %s', installed)
else:
downloaded = ' '.join([
req.name
for req in requirement_set.successfully_downloaded
])
if downloaded:
logger.info(
'Successfully downloaded %s', downloaded
possible_lib_locations = get_lib_location_guesses(
user=options.use_user_site,
home=temp_target_dir,
root=options.root_path,
prefix=options.prefix_path,
isolated=options.isolated_mode,
)
reqs = sorted(
requirement_set.successfully_installed,
key=operator.attrgetter('name'))
items = []
for req in reqs:
item = req.name
try:
installed_version = get_installed_version(
req.name, possible_lib_locations
)
if installed_version:
item += '-' + installed_version
except Exception:
pass
items.append(item)
installed = ' '.join(items)
if installed:
logger.info('Successfully installed %s', installed)
except PreviousBuildDirError:
options.no_clean = True
raise

View File

@ -141,7 +141,7 @@ class Installed(DistAbstraction):
class RequirementSet(object):
def __init__(self, build_dir, src_dir, download_dir, upgrade=False,
def __init__(self, build_dir, src_dir, download_dir=None, upgrade=False,
upgrade_strategy=None, ignore_installed=False,
target_dir=None, ignore_dependencies=False,
force_reinstall=False, use_user_site=False, session=None,

View File

@ -143,45 +143,6 @@ def test_install_editable_from_svn(script):
result.assert_installed('version-pkg', with_files=['.svn'])
@pytest.mark.network
def test_download_editable_to_custom_path(script, tmpdir):
"""
Test downloading an editable using a relative custom src folder.
"""
script.scratch_path.join("customdl").mkdir()
result = script.pip(
'install',
'-e',
'%s#egg=initools' %
local_checkout(
'svn+http://svn.colorstudy.com/INITools/trunk',
tmpdir.join("cache")
),
'--src',
'customsrc',
'--download',
'customdl',
expect_stderr=True
)
customsrc = Path('scratch') / 'customsrc' / 'initools'
assert customsrc in result.files_created, (
sorted(result.files_created.keys())
)
assert customsrc / 'setup.py' in result.files_created, (
sorted(result.files_created.keys())
)
customdl = Path('scratch') / 'customdl' / 'initools'
customdl_files_created = [
filename for filename in result.files_created
if filename.startswith(customdl)
]
assert customdl_files_created
assert ('DEPRECATION: pip install --download has been deprecated and will '
'be removed in the future. Pip now has a download command that '
'should be used instead.') in result.stderr
def _test_install_editable_from_git(script, tmpdir, wheel):
"""Test cloning from Git."""
if wheel:

View File

@ -1,150 +0,0 @@
import os
import textwrap
import pytest
from tests.lib.path import Path
@pytest.mark.network
def test_download_if_requested(script):
"""
It should download (in the scratch path) and not install if requested.
"""
result = script.pip(
'install', 'INITools==0.1', '-d', '.', expect_error=True
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
def test_download_wheel(script, data):
"""
Test using "pip install --download" to download a *.whl archive.
"""
result = script.pip(
'install',
'--no-index',
'-f', data.packages,
'-d', '.', 'meta',
expect_stderr=True,
)
assert (
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl'
in result.files_created
)
assert script.site_packages / 'piptestpackage' not in result.files_created
@pytest.mark.network
def test_single_download_from_requirements_file(script):
"""
It should support download (in the scratch path) from PyPi from a
requirements file
"""
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
INITools==0.1
"""))
result = script.pip(
'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
@pytest.mark.network
def test_download_should_download_dependencies(script):
"""
It should download dependencies (in the scratch path)
"""
result = script.pip(
'install', 'Paste[openid]==1.7.5.1', '-d', '.', expect_error=True,
)
assert Path('scratch') / 'Paste-1.7.5.1.tar.gz' in result.files_created
openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
assert any(
path.startswith(openid_tarball_prefix) for path in result.files_created
)
assert script.site_packages / 'openid' not in result.files_created
def test_download_wheel_archive(script, data):
"""
It should download a wheel archive path
"""
wheel_filename = 'colander-0.9.9-py2.py3-none-any.whl'
wheel_path = os.path.join(data.find_links, wheel_filename)
result = script.pip(
'install', wheel_path,
'-d', '.', '--no-deps',
expect_stderr=True,
)
assert Path('scratch') / wheel_filename in result.files_created
def test_download_should_download_wheel_deps(script, data):
"""
It should download dependencies for wheels(in the scratch path)
"""
wheel_filename = 'colander-0.9.9-py2.py3-none-any.whl'
dep_filename = 'translationstring-1.1.tar.gz'
wheel_path = os.path.join(data.find_links, wheel_filename)
result = script.pip(
'install', wheel_path,
'-d', '.', '--find-links', data.find_links, '--no-index',
expect_stderr=True,
)
assert Path('scratch') / wheel_filename in result.files_created
assert Path('scratch') / dep_filename in result.files_created
@pytest.mark.network
def test_download_should_skip_existing_files(script):
"""
It should not download files already existing in the scratch dir
"""
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
INITools==0.1
"""))
result = script.pip(
'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
# adding second package to test-req.txt
script.scratch_path.join("test-req.txt").write(textwrap.dedent("""
INITools==0.1
python-openid==2.2.5
"""))
# only the second package should be downloaded
result = script.pip(
'install', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
assert any(
path.startswith(openid_tarball_prefix) for path in result.files_created
)
assert Path('scratch') / 'INITools-0.1.tar.gz' not in result.files_created
assert script.site_packages / 'initools' not in result.files_created
assert script.site_packages / 'openid' not in result.files_created
@pytest.mark.network
def test_download_vcs_link(script):
"""
It should allow -d flag for vcs links, regression test for issue #798.
"""
result = script.pip(
'install', '-d', '.', 'git+git://github.com/pypa/pip-test-package.git',
expect_stderr=True,
)
assert (
Path('scratch') / 'pip-test-package-0.1.1.zip'
in result.files_created
)
assert script.site_packages / 'piptestpackage' not in result.files_created