mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #7577 from uranusjr/unicode-path-fixes-2
This commit is contained in:
commit
e0b2d96fb2
3 changed files with 20 additions and 3 deletions
0
news/7577.trivial
Normal file
0
news/7577.trivial
Normal file
|
@ -83,7 +83,13 @@ def tmpdir_factory(request, tmpdir_factory):
|
|||
"""
|
||||
yield tmpdir_factory
|
||||
if not request.config.getoption("--keep-tmpdir"):
|
||||
tmpdir_factory.getbasetemp().remove(ignore_errors=True)
|
||||
# py.path.remove() uses str paths on Python 2 and cannot
|
||||
# handle non-ASCII file names. This works around the problem by
|
||||
# passing a unicode object to rmtree().
|
||||
shutil.rmtree(
|
||||
six.text_type(tmpdir_factory.getbasetemp()),
|
||||
ignore_errors=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -103,6 +109,9 @@ def tmpdir(request, tmpdir):
|
|||
# This should prevent us from needing a multiple gigabyte temporary
|
||||
# directory while running the tests.
|
||||
if not request.config.getoption("--keep-tmpdir"):
|
||||
# py.path.remove() uses str paths on Python 2 and cannot
|
||||
# handle non-ASCII file names. This works around the problem by
|
||||
# passing a unicode object to rmtree().
|
||||
shutil.rmtree(six.text_type(tmpdir), ignore_errors=True)
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from textwrap import dedent
|
|||
from zipfile import ZipFile
|
||||
|
||||
import pytest
|
||||
from pip._vendor.six import PY2, ensure_binary
|
||||
from pip._vendor.six import PY2, ensure_binary, text_type
|
||||
from scripttest import FoundDir, TestFileEnvironment
|
||||
|
||||
from pip._internal.index.collector import LinkCollector
|
||||
|
@ -1052,8 +1052,16 @@ def create_basic_wheel_for_package(
|
|||
path.parent.mkdir(exist_ok=True, parents=True)
|
||||
path.write_bytes(ensure_binary(files[fname]))
|
||||
|
||||
# The base_dir cast is required to make `shutil.make_archive()` use
|
||||
# Unicode paths on Python 2, making it able to properly archive
|
||||
# files with non-ASCII names.
|
||||
retval = script.scratch_path / archive_name
|
||||
generated = shutil.make_archive(retval, 'zip', script.temp_path)
|
||||
generated = shutil.make_archive(
|
||||
retval,
|
||||
'zip',
|
||||
root_dir=script.temp_path,
|
||||
base_dir=text_type(os.curdir),
|
||||
)
|
||||
shutil.move(generated, retval)
|
||||
|
||||
shutil.rmtree(script.temp_path)
|
||||
|
|
Loading…
Reference in a new issue