Skip to content
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 docs/changelog/2780.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Force UTF-8 encoding for pip download
Contributed by :user:`esafak`.
2 changes: 1 addition & 1 deletion src/virtualenv/seed/wheels/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def find_compatible_in_house(distribution, version_spec, for_py_version, in_fold

def pip_wheel_env_run(search_dirs, app_data, env):
env = env.copy()
env.update({"PIP_USE_WHEEL": "1", "PIP_USER": "0", "PIP_NO_INPUT": "1"})
env.update({"PIP_USE_WHEEL": "1", "PIP_USER": "0", "PIP_NO_INPUT": "1", "PYTHONIOENCODING": "utf-8"})
wheel = get_wheel(
distribution="pip",
version=None,
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/seed/wheels/test_acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ def test_download_fails(mocker, for_py_version, session_app_data):
] == exc.cmd


def test_download_wheel_python_io_encoding(mocker, for_py_version, session_app_data):
mock_popen = mocker.patch("virtualenv.seed.wheels.acquire.Popen")
mock_popen.return_value.communicate.return_value = "Saved a-b-c.whl", ""
mock_popen.return_value.returncode = 0
mocker.patch("pathlib.Path.absolute", return_value=Path("a-b-c.whl"))

download_wheel("pip", "==1", for_py_version, [], session_app_data, "folder", os.environ.copy())

env = mock_popen.call_args[1]["env"]
assert env["PYTHONIOENCODING"] == "utf-8"


@pytest.fixture
def downloaded_wheel(mocker):
wheel = Wheel.from_path(Path("setuptools-0.0.0-py2.py3-none-any.whl"))
Expand Down
Loading