@@ -87,14 +87,14 @@ logical path to a directory containing a virtual environment, nor whether
8787logical paths should be resolved to their physical equivalent before use.
8888
8989Instead of a directory containing a virtual environment, the root of a project
90- MAY have a :file: `.venv ` redirect file. This file acts as a pointer to where
91- the (current) virtual environment to be used for the project is located
92- (which, just like a :file: ` .venv ` directory, can be a logical or pysical path) .
90+ MAY have a :file: `.venv ` redirect file (which, just like a :file: ` .venv `
91+ directory, can be a logical or pysical path). This file acts as a pointer to
92+ where the (current) virtual environment to be used for the project is located .
9393This virtual environment may not be the only environment associated with the
9494project, but it is considered the preferred virtual environment to use
9595*at the moment * by other tools. The tool managing the virtual environment
9696SHOULD update any :file: `.venv ` redirect file as appropriate when the tool or
97- the user desire a different virtual environment to be used by default by other
97+ the user desires a different virtual environment to be used by default by other
9898tools.
9999
100100Tools looking for a virtual environment SHOULD look for either a :file: `.venv `
@@ -107,10 +107,14 @@ either ``\n`` or ``\r\n`` is allowed and MUST be ignored. An empty file or one
107107that only contains a newline is considered invalid.
108108
109109The line in the :file: `.venv ` redirect file MUST point to a directory
110- containing a virtual environment when being written. The path MAY use POSIX
111- path separators-- ``/ `` --regardless of what the operating system's native path
112- separator is. The path MAY be relative, and if so MUST be relative to the
113- directory containing the :file: `.venv ` file.
110+ containing a virtual environment at the time of being written. The path MAY use
111+ POSIX path separators-- ``/ `` --regardless of what the operating system's
112+ native path separator is. The path MAY be relative; IF the path is relative
113+ THEN it MUST be resolved relative to the directory containing the :file: `.venv `
114+ redirect file based on the file's physical path (e.g., for a redirect file with
115+ a logical path of :file: `/my/.venv ` and a physical path of
116+ :file: `/some/project/.venv `, the file contents of ``../target `` resolves to
117+ :file: `/some/target `).
114118
115119With regard to committing a :file: `.venv ` redirect file to version control, it
116120MAY be done when the location of the virtual environment is considered static
@@ -167,9 +171,9 @@ to tell other tools where to find the virtual environment to use. That's the
167171purpose of the :file: `.venv ` redirect file. The file itself is hidden as it
168172isn't a critical aspect of the project (environments themselves can be viewed
169173as implementation details). The file name was chosen to match the :file: `.venv `
170- directory name as the purpose of a path with that name is already well known.
171- As well, it is already broadly ignored by projects, so it won't lead to
172- projects suddenly having a new file that they may accidentally commit.
174+ directory name as the purpose of a directory with that name is already
175+ well-known. As well, it is already broadly ignored by projects, so it won't
176+ lead to projects suddenly having a new file that they may accidentally commit.
173177
174178The :file: `.venv ` redirect file format is simple to allow for easy
175179manipulation. It is easy to write a line to a :file: `.venv ` file via the
@@ -205,6 +209,13 @@ name or ownership of the virtual environment, but e.g., virtual environments
205209have the prompt recorded in :file: `pyvenv.cfg `, so it does not need to be
206210listed separately from the environment where it may become stale.
207211
212+ The discussion identified ambiguity about resolving relative paths in a
213+ :file: `.venv ` redirect file when logical paths for the redirect file itself are
214+ involved. A logical path could refer to the redirect file itself or to any part
215+ of its containing directory. To solve the ambiguity, the path to the redirect
216+ file MUST be resolved to a physical path before any relative path contained in
217+ the redirect file is resolved.
218+
208219While some projects may have multiple virtual environments available, the
209220concept of a current or default virtual environment is a constant. And saying
210221other tools shouldn't overwrite a :file: `.venv ` redirect file they didn't
@@ -465,6 +476,11 @@ this PEP.
465476Change History
466477==============
467478
479+ - 26-Oct-2026
480+
481+ - Require relative paths in a redirect file to be resolved relative to the
482+ directory of the physical path of the redirect file
483+
468484- 24-Sep-2026
469485
470486 - Clarify :file: `.venv ` redirect files can be logical or physical paths just
0 commit comments