[BUG] lenient mode for editable install does not work with the --system-site-packages option of venv
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the editable install with venv's --system-site-packages option and inspect venv/Lib/site-packages/__editable___package_x_finder.py, especially its MAPPING entry. Compare the lenient behavior with editable_mode=compat, then verify that the finder selects the package in the virtual environment and that python -m package_x runs that copy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100