Skip to content

Commit f41ed51

Browse files
committed
Merge branch 'relative.venvs' of https://github.com/rickeylev/peps into relative.venvs
2 parents 560dadb + 5b259cc commit f41ed51

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

peps/pep-0796.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Type: Standards Track
88
Created: 26-Jun-2025
99
Python-Version: 3.15
1010

11-
.. highlight:: rst
12-
1311

1412
Abstract
1513
========
@@ -42,7 +40,7 @@ requirement should be relaxed and relative path behavior allowed and defined.
4240

4341
Second, such relative paths are a building block to enable portable virtual
4442
environments, 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
4644
are a popular mechanism for running Python applications. This provides several
4745
benefits:
4846

@@ -60,7 +58,7 @@ host that intends to run the program.
6058
When the virtual environment doesn't require modifications to be usable, it
6159
also allows more advanced deployment mechanisms, e.g. remote mounting and
6260
caching 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
6462
constrained environments that allow for such use cases.
6563

6664
Rationale
@@ -75,10 +73,10 @@ so other hook points (e.g. ``site`` initialization) never trigger.
7573

7674
Tools that currently look to enable virtual environment portability across
7775
machines 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
7977
dependent fallback to resolving via a symlinked interpreter binary on
8078
non-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

8381
Specification
8482
=============
@@ -87,10 +85,10 @@ The ``home`` value in ``pyvenv.cfg`` is permitted to use a relative path value.
8785
These may contain up-references outside of the virtual environment root
8886
directory. 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

9593
Relative paths are relative to the directory containing ``pyvenv.cfg``. During
9694
interpreter 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
134132
paths.
135133

136134
A 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

139137
Backwards 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
145143
moving the environment) will be unaffected.
146144

147145
While the PEP author and sponsor aren't aware of any projects that work around
@@ -159,9 +157,10 @@ accordingly.
159157
How 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``,
163161
then 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

167166
Reference 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

199198
Rejected Ideas
200199
=====================

0 commit comments

Comments
 (0)