Use filesystem compatible encodings for strings

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2018-05-27 13:52:39 -04:00
parent cc68b365e0
commit e993ee874d
3 changed files with 32 additions and 12 deletions
+5 -2
View File
@@ -29,6 +29,11 @@ except ImportError:
_types.add(type(arg))
return _types.pop()
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path
try:
from weakref import finalize
@@ -51,8 +56,6 @@ if six.PY2:
class ResourceWarning(Warning):
pass
# -*- coding=utf-8 -*-
def pip_import(module_path, subimport=None, old_path=None):
internal = 'pip._internal.{0}'.format(module_path)
+11 -7
View File
@@ -46,10 +46,12 @@ from .utils import (
rmtree,
split_argument,
extract_uri_from_vcs_dep,
fs_str,
)
from ._compat import (
TemporaryDirectory,
vcs
vcs,
Path
)
from .import pep508checker, progress
from .environments import (
@@ -1495,20 +1497,22 @@ def pip_install(
)
if verbose:
click.echo('$ {0}'.format(pip_command), err=True)
cache_dir = Path(PIPENV_CACHE_DIR)
pip_config = {
'PIP_CACHE_DIR': PIPENV_CACHE_DIR,
'PIP_WHEEL_DIR': os.path.join(PIPENV_CACHE_DIR, 'wheels'),
'PIP_DESTINATION_DIR': os.path.join(PIPENV_CACHE_DIR, 'pkgs'),
'PIP_CACHE_DIR': fs_str(cache_dir.as_posix()),
'PIP_WHEEL_DIR': fs_str(cache_dir.joinpath('wheels').as_posix()),
'PIP_DESTINATION_DIR': fs_str(cache_dir.joinpath('pkgs').as_posix()),
}
c = delegator.run(pip_command, block=block, env=pip_config)
return c
def pip_download(package_name):
cache_dir = Path(PIPENV_CACHE_DIR)
pip_config = {
'PIP_CACHE_DIR': PIPENV_CACHE_DIR,
'PIP_WHEEL_DIR': os.path.join(PIPENV_CACHE_DIR, 'wheels'),
'PIP_DESTINATION_DIR': os.path.join(PIPENV_CACHE_DIR, 'pkgs'),
'PIP_CACHE_DIR': fs_str(cache_dir.as_posix()),
'PIP_WHEEL_DIR': fs_str(cache_dir.joinpath('wheels').as_posix()),
'PIP_DESTINATION_DIR': fs_str(cache_dir.joinpath('pkgs').as_posix()),
}
for source in project.sources:
cmd = '{0} download "{1}" -i {2} -d {3}'.format(
+16 -3
View File
@@ -1189,10 +1189,9 @@ def get_vcs_deps(
lockfiles.append({pipfile_name: installed.pipfile_entry[1]})
pipfile_srcdir = escape_grouped_arguments((src_dir / pipfile_name).as_posix())
lockfile_srcdir = escape_grouped_arguments(
(src_dir / installed.normalized_name).as_posix()
)
(src_dir / installed.normalized_name))
lines.append(line)
if pipfile_srcdir.exists():
if os.path.exists(pipfile_srcdir):
lockfiles.extend(
venv_resolve_deps(
["-e {0}".format(pipfile_srcdir)],
@@ -1217,3 +1216,17 @@ def get_vcs_deps(
)
)
return lines, lockfiles
def fs_str(string):
"""Encodes a string into the proper filesystem encoding
Borrowed from pip-tools
"""
if isinstance(string, str):
return string
assert not isinstance(string, bytes)
return string.encode(_fs_encoding)
_fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()