pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.82k stars 1.03k forks source link

Calling `pip download` on non-utf system can fail if user home folder has non ASCII chars #2780

Open rressi-at-globus opened 2 weeks ago

rressi-at-globus commented 2 weeks ago

Issue

At this line:

The tool virtualenv is launching pip as a child process:

When pip runs and there are some non-asci characters with his traces we may have failures leading to out being set to None.

Environment

Provide at least:

Just bare Python embed for Windows:

Very very important to reproduce this issue:

The command which is failing:

{
    "args": [
        "C:/Development/gm-venv/bootstrap_3.12.6-1a8994a/python.exe",
        "-m",
        "virtualenv",
        "C:/Development/gm-venv/venv_da29d03",
        "--always-copy",
        "--download",
        "--prompt",
        "venv_da29d03"
    ],
    "cwd": "C:/Development/gm-venv",
    "env": {
        ...
    }

Note: by adding to the environment "PYTHONIOENCODING": "utf-8", the issue is worked around and everything is fine.

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

fail
Traceback (most recent call last):
  File "C:\Development\gm-venv\bootstrap_3.12.6-1a8994a\Lib\site-packages\virtualenv\seed\embed\via_app_data\via_app_data.py", line 84, in _get
    result = get_wheel(
             ^^^^^^^^^^
  File "C:\Development\gm-venv\bootstrap_3.12.6-1a8994a\Lib\site-packages\virtualenv\seed\wheels\acquire.py", line 36, in get_wheel
    wheel = download_wheel(
            ^^^^^^^^^^^^^^^
  File "C:\Development\gm-venv\bootstrap_3.12.6-1a8994a\Lib\site-packages\virtualenv\seed\wheels\acquire.py", line 77, in download_wheel
    result = _find_downloaded_wheel(distribution, version_spec, for_py_version, to_folder, out)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Development\gm-venv\bootstrap_3.12.6-1a8994a\Lib\site-packages\virtualenv\seed\wheels\acquire.py", line 83, in _find_downloaded_wheel
    for line in out.splitlines():
                ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'splitlines'
gaborbernat commented 2 weeks ago

PR welcome 😊