@@ -8,8 +8,6 @@ Type: Standards Track
88Created: 26-Jun-2025
99Python-Version: 3.15
1010
11- .. highlight :: rst
12-
1311
1412Abstract
1513========
@@ -42,7 +40,7 @@ requirement should be relaxed and relative path behavior allowed and defined.
4240
4341Second, such relative paths are a building block to enable portable virtual
4442environments, i.e. copying a virtual environment as-is between hosts of
45- compatible platforms. Portable venvs are appealing because virtual environments
43+ compatible platforms. Portable virtual environments are appealing because virtual environments
4644are a popular mechanism for running Python applications. This provides several
4745benefits:
4846
@@ -60,7 +58,7 @@ host that intends to run the program.
6058When the virtual environment doesn't require modifications to be usable, it
6159also allows more advanced deployment mechanisms, e.g. remote mounting and
6260caching of artifacts. While this PEP on its own isn't sufficient to enable
63- that, it allows tools like `` bazel `` or `` venvstacks `` to more easily prepare
61+ that, it allows tools like Bazel or venvstacks to more easily prepare
6462constrained environments that allow for such use cases.
6563
6664Rationale
@@ -75,10 +73,10 @@ so other hook points (e.g. ``site`` initialization) never trigger.
7573
7674Tools that currently look to enable virtual environment portability across
7775machines do so either by relying on undocumented interpreter behaviour
78- (`` bazel `` , omitting the ``home `` key entirely to trigger an implementation
76+ (Bazel , omitting the ``home `` key entirely to trigger an implementation
7977dependent fallback to resolving via a symlinked interpreter binary on
8078non-Windows systems) or by requiring a post-installation script to be executed
81- after the environment is placed in its target location (`` venvstacks `` ).
79+ after the environment is placed in its target location (venvstacks).
8280
8381Specification
8482=============
@@ -87,10 +85,10 @@ The ``home`` value in ``pyvenv.cfg`` is permitted to use a relative path value.
8785These may contain up-references outside of the virtual environment root
8886directory. Examples:
8987
90- * ``subdir/whatever/bin `` (a directory within the virtual environment).
88+ * ``subdir/whatever/bin `` (a directory within the virtual environment)
9189* ``./subdir/whatever/bin `` (same as above)
9290* ``../../../../../elsewhere/runtime/bin `` (a directory outside the virtual
93- environment).
91+ environment)
9492
9593Relative paths are relative to the directory containing ``pyvenv.cfg ``. During
9694interpreter startup (i.e. ``getpath.py ``), the relative path is joined to the
@@ -134,14 +132,14 @@ helpers already present for checking if a path is absolute and joining two
134132paths.
135133
136134A proof-of-concept of this is implemented in
137- `rickeylev/feat.relative.pyvenv.home <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home >`__
135+ `rickeylev/feat.relative.pyvenv.home <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home >`__.
138136
139137Backwards Compatibility
140138=======================
141139
142140
143- Tools that work around the absolute ``home `` key limitation the way `` bazel ``
144- and `` venvstacks `` currently do (omitting the ``home `` key, or editing it after
141+ Tools that work around the absolute ``home `` key limitation the way Bazel
142+ and venvstacks currently do (omitting the ``home `` key, or editing it after
145143moving the environment) will be unaffected.
146144
147145While the PEP author and sponsor aren't aware of any projects that work around
@@ -159,9 +157,10 @@ accordingly.
159157How to Teach This
160158=================
161159
162- Teaching this should be simple : if you use a relative path in ``pyvenv.cfg ``,
160+ Teaching this should be straightforward : if you use a relative path in ``pyvenv.cfg ``,
163161then it's relative to the directory containing the ``pyvenv.cfg `` file. This
164- is simple to explain and understand.
162+ is simple to explain and easy to understand for anyone that is already familiar
163+ with handling relative filesystem paths.
165164
166165
167166Reference Implementation
@@ -189,12 +188,12 @@ References
189188 host-relocatable virtual environments.
190189* `rules_py <https://github.com/aspect-build/rules_py >`__: implements
191190 host-relocatable virtual environments.
192- * `python-build-standalone <https://github.com/astral-sh/python-build-standalone >`__:
191+ * `python-build-standalone <https://github.com/astral-sh/python-build-standalone >`__
193192* `venvstacks <https://pypi.org/project/venvstacks/ >`__: a tool for creating reproducible distribution artifacts from virtual environments
194193 A relocatable Python runtime.
195194* `PoC for relative home in Python startup <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home >`__
196195* `Python Ideas "Making venvs relocatable friendly" discussion <https://discuss.python.org/t/making-venvs-relocatable-friendly/96177 >`__
197- * `GH -136051: relative pyvenv.cfg home <https://github.com/python/cpython/issues/136051 >`__
196+ * `gh -136051: relative pyvenv.cfg home <https://github.com/python/cpython/issues/136051 >`__
198197
199198Rejected Ideas
200199=====================
0 commit comments