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

Remove svn handling in unpacking.unpack_file #7037

Merged
merged 4 commits into from
Sep 19, 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
2 changes: 2 additions & 0 deletions news/7037.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove undocumented support for http:// requirements pointing to SVN
repositories.
4 changes: 2 additions & 2 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def unpack_http_url(

# unpack the archive to the build dir location. even when only
# downloading archives, they have to be unpacked to parse dependencies
unpack_file(from_path, location, content_type, link)
unpack_file(from_path, location, content_type)

# a download dir is specified; let's copy the archive there
if download_dir and not already_downloaded_path:
Expand Down Expand Up @@ -1120,7 +1120,7 @@ def unpack_file_url(

# unpack the archive to the build dir location. even when only downloading
# archives, they have to be unpacked to parse dependencies
unpack_file(from_path, location, content_type, link)
unpack_file(from_path, location, content_type)

# a download dir is specified and not already downloaded
if download_dir and not already_downloaded_path:
Expand Down
33 changes: 2 additions & 31 deletions src/pip/_internal/utils/unpacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import logging
import os
import re
import shutil
import stat
import tarfile
Expand All @@ -21,13 +20,11 @@
XZ_EXTENSIONS,
ZIP_EXTENSIONS,
)
from pip._internal.utils.misc import ensure_dir, hide_url
from pip._internal.utils.misc import ensure_dir
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Iterable, List, Optional, Match, Text, Union

from pip._internal.models.link import Link
from typing import Iterable, List, Optional, Text, Union


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,23 +53,6 @@ def current_umask():
return mask


def file_contents(filename):
# type: (str) -> Text
with open(filename, 'rb') as fp:
return fp.read().decode('utf-8')


def is_svn_page(html):
# type: (Union[str, Text]) -> Optional[Match[Union[str, Text]]]
"""
Returns true if the page appears to be the index page of an svn repository
"""
return (
re.search(r'<title>[^<]*Revision \d+:', html) and
re.search(r'Powered by (?:<a[^>]*?>)?Subversion', html, re.I)
)


def split_leading_dir(path):
# type: (Union[str, Text]) -> List[Union[str, Text]]
path = path.lstrip('/').lstrip('\\')
Expand Down Expand Up @@ -231,7 +211,6 @@ def unpack_file(
filename, # type: str
location, # type: str
content_type, # type: Optional[str]
link # type: Optional[Link]
):
# type: (...) -> None
filename = os.path.realpath(filename)
Expand All @@ -253,14 +232,6 @@ def unpack_file(
)
):
untar_file(filename, location)
elif (
content_type and content_type.startswith('text/html') and
is_svn_page(file_contents(filename))
):
# We don't really care about this
from pip._internal.vcs.subversion import Subversion
hidden_url = hide_url('svn+' + link.url)
Subversion().unpack(location, url=hidden_url)
else:
# FIXME: handle?
# FIXME: magic signatures?
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ def test_wheel_version(tmpdir, data):
future_version = (1, 9)

unpack_file(data.packages.joinpath(future_wheel),
tmpdir + 'future', None, None)
tmpdir + 'future', None)
unpack_file(data.packages.joinpath(broken_wheel),
tmpdir + 'broken', None, None)
tmpdir + 'broken', None)

assert wheel.wheel_version(tmpdir + 'future') == future_version
assert not wheel.wheel_version(tmpdir + 'broken')
Expand Down Expand Up @@ -593,7 +593,7 @@ def test_support_index_min__none_supported(self):
def test_unpack_wheel_no_flatten(self, tmpdir):
filepath = os.path.join(DATA_DIR, 'packages',
'meta-1.0-py2.py3-none-any.whl')
unpack_file(filepath, tmpdir, 'application/zip', None)
unpack_file(filepath, tmpdir, 'application/zip')
assert os.path.isdir(os.path.join(tmpdir, 'meta-1.0.dist-info'))

def test_purelib_platlib(self, data):
Expand Down Expand Up @@ -633,7 +633,7 @@ def prep(self, data, tmpdir):
self.req = Requirement('sample')
self.src = os.path.join(tmpdir, 'src')
self.dest = os.path.join(tmpdir, 'dest')
unpack_file(self.wheelpath, self.src, None, None)
unpack_file(self.wheelpath, self.src, None)
self.scheme = {
'scripts': os.path.join(self.dest, 'bin'),
'purelib': os.path.join(self.dest, 'lib'),
Expand Down