Tell shutil.make_archive to use Unicode paths

By default, make_archive uses str paths on Python 2, which causes it to
skip files with unencodable names. By passing in a unicode base_dir
explicitly, it is smart enough to use unicode all the way down instead.
This commit is contained in:
Tzu-ping Chung 2020-01-09 13:01:31 +05:30
parent 37f97140af
commit 7a80acaf44
1 changed files with 7 additions and 2 deletions

View File

@ -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
@ -1053,7 +1053,12 @@ def create_basic_wheel_for_package(
path.write_bytes(ensure_binary(files[fname]))
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)