Skip to content

python -m venv --copies attempts to create a symlink regardless of if it's supported by the filesystem #98975

@stiege

Description

@stiege

Bug report

https://bugs.python.org/issue21197 added a lib64 symlink for compatibility on POSIX systems. venv's behaviour differs from virtualenvs in that virtualenv does a check to see if the filesystem is able to symlink (https://github.com/pypa/virtualenv/blob/b85542c31ca8afcff317e618da434f59fa06d122/src/virtualenv/info.py#L28-L47)

https://bugs.python.org/msg219258

If the filesystem does not support symlinks (i.e. FAT) the exception is unhandled and the process exits - leaving the virtual environment structure unfinished. The issue can be worked around by creating a directory in the symlink's location before invoking venv (

if not os.path.exists(link_path): # Issue #21643
).

Ideally venv would do a similar check to virtualenv or silently ignore the exception as this is just for POSIX compatibility purposes anyway (and the edge-case is already ignored of the directory existing).

Your environment

root@650ae388ee44:~# python --version
Python 3.10.4
root@650ae388ee44:~# python -m venv venv --copies  # Throws an exception on FAT fs, venv unfinished
root@650ae388ee44:~# find venv/ -type l  # gah, a symlink
venv/lib64
root@650ae388ee44:~# rm -rf venv/
root@650ae388ee44:~# mkdir -p venv/lib64  # Workaround
root@650ae388ee44:~# python -m venv venv --copies
root@650ae388ee44:~# find venv/ -type l
root@650ae388ee44:~#

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-venvRelated to the venv moduletype-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions