Skip to content

[BUG] lenient mode for editable install does not work with the --system-site-packages option of venv #3828

Open
@JulienGrv

Description

@JulienGrv

setuptools version

setuptools==67.1.0

Python version

Python 3.8.16

OS

Windows

Additional environment information

No response

Description

venv has an option called --system-site-packages which means that when you are in a virtual environment, you can still import and use a package from your system if it is absent in your venv. In the case a package is both installed on the system and in the venv, the one in the venv has precedence over the one from the system. However, since the introduction of the new default lenient mode for editable install, this does not work as expected and the package from the system is used instead of the one in the venv. Currently, this issue can be worked around using editable_mode=compat.

Expected behavior

The package in venv should have precedence over the one in system. Finder script should map to the package in venv, not in system.

How to Reproduce

pip install <package_x> # install package_x on your system
python -m venv --system-site-packages venv # create venv with --system-site-packages
source venv/Scripts/activate # activate venv
pip install --editable <path_to_package_x> # install package_x in venv with --editable
python -m package_x  # will run package_x from system instead of from venv
cat venv/Lib/site-packages/__editable___package_x_finder.py | grep 'MAPPING =' # will show you that it wrongly maps to the package in system instead of venv
pip install --editable <path_to_package_x> --config-settings editable_mode=compat # workaround using compat mode
python -m package_x # will correctly run package_x from venv

PS: please do not remove the compat mode as long as the lenient mode is not fully functioning

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions