Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete some dead code #6129

Merged
merged 6 commits into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
1 change: 0 additions & 1 deletion src/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
class Command(object):
name = None # type: Optional[str]
usage = None # type: Optional[str]
hidden = False # type: bool
ignore_require_venv = False # type: bool

def __init__(self, isolated=False):
Expand Down
44 changes: 3 additions & 41 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
from pip._internal.utils.encoding import auto_decode
from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.glibc import libc_ver
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS, ask_path_exists, backup_dir, call_subprocess, consume,
display_path, format_size, get_installed_version, rmtree,
split_auth_from_netloc, splitext, unpack_file,
ARCHIVE_EXTENSIONS, ask_path_exists, backup_dir, consume, display_path,
format_size, get_installed_version, rmtree, split_auth_from_netloc,
splitext, unpack_file,
)
from pip._internal.utils.setuptools_build import SETUPTOOLS_SHIM
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.ui import DownloadProgressProvider
Expand Down Expand Up @@ -767,42 +765,6 @@ def unpack_file_url(
_copy_file(from_path, download_dir, link)


def _copy_dist_from_dir(link_path, location):
"""Copy distribution files in `link_path` to `location`.

Invoked when user requests to install a local directory. E.g.:

pip install .
pip install ~/dev/git-repos/python-prompt-toolkit

"""

# Note: This is currently VERY SLOW if you have a lot of data in the
# directory, because it copies everything with `shutil.copytree`.
# What it should really do is build an sdist and install that.
# See https://github.com/pypa/pip/issues/2195

if os.path.isdir(location):
rmtree(location)

# build an sdist
setup_py = 'setup.py'
sdist_args = [sys.executable]
sdist_args.append('-c')
sdist_args.append(SETUPTOOLS_SHIM % setup_py)
sdist_args.append('sdist')
sdist_args += ['--dist-dir', location]
logger.info('Running setup.py sdist for %s', link_path)

with indent_log():
call_subprocess(sdist_args, cwd=link_path)

# unpack sdist into `location`
sdist = os.path.join(location, os.listdir(location)[0])
logger.info('Unpacking sdist %s into %s', sdist, location)
unpack_file(sdist, location, content_type=None, link=None)


class PipXmlrpcTransport(xmlrpc_client.Transport):
"""Provide a `xmlrpclib.Transport` implementation via a `PipSession`
object.
Expand Down
6 changes: 0 additions & 6 deletions src/pip/_internal/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ def has_requirement(self, project_name):
return True
return False

@property
def has_requirements(self):
# type: () -> List[InstallRequirement]
return list(req for req in self.requirements.values() if not
req.constraint) or self.unnamed_requirements

def get_requirement(self, project_name):
# type: (str) -> InstallRequirement
for name in project_name, project_name.lower():
Expand Down
27 changes: 0 additions & 27 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import contextlib
import errno
import io
import locale
# we have a submodule named 'logging' which would shadow this if we used the
# regular name:
import logging as std_logging
Expand Down Expand Up @@ -774,32 +773,6 @@ def call_subprocess(
return None


def read_text_file(filename):
# type: (str) -> str
"""Return the contents of *filename*.

Try to decode the file contents with utf-8, the preferred system encoding
(e.g., cp1252 on some Windows machines), and latin1, in that order.
Decoding a byte string with latin1 will never raise an error. In the worst
case, the returned string will contain some garbage characters.

"""
with open(filename, 'rb') as fp:
data = fp.read()

encodings = ['utf-8', locale.getpreferredencoding(False), 'latin1']
for enc in encodings:
try:
# https://github.com/python/mypy/issues/1174
data = data.decode(enc) # type: ignore
except UnicodeDecodeError:
continue
break

assert not isinstance(data, bytes) # Latin1 should have worked.
return data


def _make_build_dir(build_dir):
os.makedirs(build_dir)
write_delete_marker_file(build_dir)
Expand Down
19 changes: 1 addition & 18 deletions src/pip/_internal/utils/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from signal import SIGINT, default_int_handler, signal

from pip._vendor import six
from pip._vendor.progress.bar import (
Bar, ChargingBar, FillingCirclesBar, FillingSquaresBar, IncrementalBar,
ShadyBar,
)
from pip._vendor.progress.bar import Bar, FillingCirclesBar, IncrementalBar
from pip._vendor.progress.helpers import HIDE_CURSOR, SHOW_CURSOR, WritelnMixin
from pip._vendor.progress.spinner import Spinner

Expand Down Expand Up @@ -216,20 +213,6 @@ class DownloadIncrementalBar(BaseDownloadProgressBar, # type: ignore
pass


class DownloadChargingBar(BaseDownloadProgressBar, # type: ignore
ChargingBar):
pass


class DownloadShadyBar(BaseDownloadProgressBar, ShadyBar): # type: ignore
pass


class DownloadFillingSquaresBar(BaseDownloadProgressBar, # type: ignore
FillingSquaresBar):
pass


class DownloadFillingCirclesBar(BaseDownloadProgressBar, # type: ignore
FillingCirclesBar):
pass
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ def test_help_commands_equally_functional(in_memory_pip):
assert all(len(o) > 0 for o in out)

for name, cls in commands.items():
if cls.hidden:
continue

assert (
in_memory_pip.pip('help', name).stdout ==
in_memory_pip.pip(name, '--help').stdout != ""
Expand Down
18 changes: 1 addition & 17 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tempfile

import pytest
from mock import Mock, mock_open, patch
from mock import patch
from pip._vendor import pkg_resources
from pip._vendor.packaging.markers import Marker
from pip._vendor.packaging.requirements import Requirement
Expand All @@ -23,7 +23,6 @@
from pip._internal.req.req_file import process_line
from pip._internal.req.req_tracker import RequirementTracker
from pip._internal.resolve import Resolver
from pip._internal.utils.misc import read_text_file
from tests.lib import DATA_DIR, assert_raises_regexp, requirements_file


Expand Down Expand Up @@ -317,21 +316,6 @@ def test_hashed_deps_on_require_hashes(self):
))


@pytest.mark.parametrize(('file_contents', 'expected'), [
(b'\xf6\x80', b'\xc3\xb6\xe2\x82\xac'), # cp1252
(b'\xc3\xb6\xe2\x82\xac', b'\xc3\xb6\xe2\x82\xac'), # utf-8
(b'\xc3\xb6\xe2', b'\xc3\x83\xc2\xb6\xc3\xa2'), # Garbage
])
def test_egg_info_data(file_contents, expected):
om = mock_open(read_data=file_contents)
em = Mock()
em.return_value = 'cp1252'
with patch('pip._internal.utils.misc.open', om, create=True):
with patch('locale.getpreferredencoding', em):
ret = read_text_file('foo')
assert ret == expected.decode('utf-8')


class TestInstallRequirement(object):
def setup(self):
self.tempdir = tempfile.mkdtemp()
Expand Down