]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94214: Add venv context.lib_path and document the context (GH-94221)
authorPaul Moore <p.f.moore@gmail.com>
Sun, 26 Jun 2022 16:49:03 +0000 (17:49 +0100)
committerGitHub <noreply@github.com>
Sun, 26 Jun 2022 16:49:03 +0000 (17:49 +0100)
Doc/library/venv.rst
Lib/venv/__init__.py
Misc/NEWS.d/next/Library/2022-06-24-14-25-26.gh-issue-94214.03pXR5.rst [new file with mode: 0644]

index b40bd4102c259336d215d7546af010da9d4eb4d9..3cf143d552ac88f649d26bb6eef278df29cb1aaf 100644 (file)
@@ -177,6 +177,45 @@ creation according to their needs, the :class:`EnvBuilder` class.
         ``clear=True``, contents of the environment directory will be cleared
         and then all necessary subdirectories will be recreated.
 
+        The returned context object is a :class:`types.SimpleNamespace` with the
+        following attributes:
+
+        * ``env_dir`` - The location of the virtual environment. Used for
+          ``__VENV_DIR__`` in activation scripts (see :meth:`install_scripts`).
+
+        * ``env_name`` - The name of the virtual environment. Used for
+          ``__VENV_NAME__`` in activation scripts (see :meth:`install_scripts`).
+
+        * ``prompt`` - The prompt to be used by the activation scripts. Used for
+          ``__VENV_PROMPT__`` in activation scripts (see :meth:`install_scripts`).
+
+        * ``executable`` - The underlying Python executable used by the virtual
+          environment. This takes into account the case where a virtual environment
+          is created from another virtual environment.
+
+        * ``inc_path`` - The include path for the virtual environment.
+
+        * ``lib_path`` - The purelib path for the virtual environment.
+
+        * ``bin_path`` - The script path for the virtual environment.
+
+        * ``bin_name`` - The name of the script path relative to the virtual
+          environment location. Used for ``__VENV_BIN_NAME__`` in activation
+          scripts (see :meth:`install_scripts`).
+
+        * ``env_exe`` - The name of the Python interpreter in the virtual
+          environment. Used for ``__VENV_PYTHON__`` in activation scripts
+          (see :meth:`install_scripts`).
+
+        * ``env_exec_cmd`` - The name of the Python interpreter, taking into
+          account filesystem redirections. This can be used to run Python in
+          the virtual environment.
+
+
+        .. versionchanged:: 3.12
+           The attribute ``lib_path`` was added to the context, and the context
+           object was documented.
+
         .. versionchanged:: 3.11
            The *venv*
            :ref:`sysconfig installation scheme <installation_paths>`
index 6032f3648e15ff8bfcb156c1b4cf2908d366ad78..f6b790e1b71a13bf8ce4a3e34554861529bde100 100644 (file)
@@ -138,6 +138,7 @@ class EnvBuilder:
 
         context.inc_path = incpath
         create_if_needed(incpath)
+        context.lib_path = libpath
         create_if_needed(libpath)
         # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
         if ((sys.maxsize > 2**32) and (os.name == 'posix') and
diff --git a/Misc/NEWS.d/next/Library/2022-06-24-14-25-26.gh-issue-94214.03pXR5.rst b/Misc/NEWS.d/next/Library/2022-06-24-14-25-26.gh-issue-94214.03pXR5.rst
new file mode 100644 (file)
index 0000000..7dccc0a
--- /dev/null
@@ -0,0 +1 @@
+Document the ``context`` object used in the ``venv.EnvBuilder`` class, and add the new environment's library path to it.