From b2eb0c8e9e9003dd6c38e0021f73795e9a02df5a Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 6 Aug 2024 11:09:34 -0400 Subject: [PATCH 1/2] gh-121103: Update site module docs for free-threaded installs --- Doc/library/site.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 1c420419568a90..14b77acbb54f7b 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -32,7 +32,8 @@ It starts by constructing up to four directories from a head and a tail part. For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads are skipped. For the tail part, it uses the empty string and then :file:`lib/site-packages` (on Windows) or -:file:`lib/python{X.Y}/site-packages` (on Unix and macOS). For each +:file:`lib/python{X.Y[t]}/site-packages` (on Unix and macOS), where the +optional suffix "t" indicates the :term:`free threading` build. For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to ``sys.path`` and also inspects the newly added path for configuration files. @@ -40,6 +41,10 @@ added path for configuration files. .. versionchanged:: 3.5 Support for the "site-python" directory has been removed. +.. versionchanged:: 3.13 + The :term:`free threading` Python installations are identified by the "t" + suffix in the version-specific directory name, such as :file:`lib/python3.13t/`. + If a file named "pyvenv.cfg" exists one directory above sys.executable, sys.prefix and sys.exec_prefix are set to that directory and it is also checked for site-packages (sys.base_prefix and @@ -188,11 +193,12 @@ Module contents Path to the user site-packages for the running Python. Can be ``None`` if :func:`getusersitepackages` hasn't been called yet. Default value is - :file:`~/.local/lib/python{X.Y}/site-packages` for UNIX and non-framework + :file:`~/.local/lib/python{X.Y}[t]/site-packages` for UNIX and non-framework macOS builds, :file:`~/Library/Python/{X.Y}/lib/python/site-packages` for macOS framework builds, and :file:`{%APPDATA%}\\Python\\Python{XY}\\site-packages` - on Windows. This directory is a site directory, which means that - :file:`.pth` files in it will be processed. + on Windows. The optional "t" indicates the free-threaded build. This + directory is a site directory, which means that :file:`.pth` files in it + will be processed. .. data:: USER_BASE From 5a06b789d94a3f2c58c6bdce2f9731135c23ce66 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 6 Aug 2024 12:38:07 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Alex Waygood --- Doc/library/site.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 14b77acbb54f7b..871cfefc8de310 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -32,8 +32,10 @@ It starts by constructing up to four directories from a head and a tail part. For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads are skipped. For the tail part, it uses the empty string and then :file:`lib/site-packages` (on Windows) or -:file:`lib/python{X.Y[t]}/site-packages` (on Unix and macOS), where the -optional suffix "t" indicates the :term:`free threading` build. For each +:file:`lib/python{X.Y[t]}/site-packages` (on Unix and macOS). (The +optional suffix "t" indicates the :term:`free threading` build, and is +appended if ``"t"`` is present in the :attr:`sys.abiflags` constant.) +For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to ``sys.path`` and also inspects the newly added path for configuration files. @@ -42,8 +44,9 @@ added path for configuration files. Support for the "site-python" directory has been removed. .. versionchanged:: 3.13 - The :term:`free threading` Python installations are identified by the "t" - suffix in the version-specific directory name, such as :file:`lib/python3.13t/`. + On Unix, :term:`Free threading ` Python installations are + identified by the "t" suffix in the version-specific directory name, such as + :file:`lib/python3.13t/`. If a file named "pyvenv.cfg" exists one directory above sys.executable, sys.prefix and sys.exec_prefix are set to that directory and