python / python/cpython

Add an option to disable `realpath` when creating venv

Open
#138,889 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-venv type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

These two lines of code sometimes make the executable path point somewhere unexpected:
https://github.com/python/cpython/blob/8b5ce31c2b44d9bf82e6119e90a52dd530bfd1db/Lib/venv/__init__.py#L210
https://github.com/python/cpython/blob/8b5ce31c2b44d9bf82e6119e90a52dd530bfd1db/Lib/venv/__init__.py#L240

Based on the following issue, realpath is necessary in some cases. However, there are situations where using "redirects, links or junctions" is intentional! For example, using subst to change drive letters or path for venv.
https://github.com/python/cpython/issues/89500

Would it be possible to add an option to disable the use of realpath during venv creation?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Lib/venv/init.py at the two linked realpath calls, then read issue 89500 to understand why realpath is needed in some cases. Determine where an opt-out belongs in venv creation and how the existing behavior should remain the default. Done means intentional redirects, links, or junctions can be preserved without breaking the cases covered by the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.