Skip to content

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

Open
@rressi-at-globus

Description

@rressi-at-globus

Issue

At this line:

The tool virtualenv is launching pip as a child process:

  • It set the I/O encoding to utf-8
  • But pip may have a different opinion as the encoding is system dependent.

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:

  • OS: Windows 11 (possibly any version of Windows)

Just bare Python embed for Windows:

Very very important to reproduce this issue:

  • The user has a home folder with non-ASCII characters in the path.
  • With another user with the home folder with only ASCII chars everything is fine.

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'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions