@@ -20,6 +20,7 @@ The :mod:`sysconfig` module provides access to Python's configuration
2020information like the list of installation paths and the configuration variables
2121relevant for the current platform.
2222
23+
2324Configuration variables
2425-----------------------
2526
@@ -60,6 +61,7 @@ Example of usage::
6061 >>> sysconfig.get_config_vars('AR', 'CXX')
6162 ['ar', 'g++']
6263
64+
6365.. _installation_paths :
6466
6567Installation paths
@@ -68,27 +70,24 @@ Installation paths
6870Python uses an installation scheme that differs depending on the platform and on
6971the installation options. These schemes are stored in :mod: `sysconfig ` under
7072unique identifiers based on the value returned by :const: `os.name `.
71-
72- Every new component that is installed using :mod: `!distutils ` or a
73- Distutils-based system will follow the same scheme to copy its file in the right
74- places.
73+ The schemes are used by package installers to determine where to copy files to.
7574
7675Python currently supports nine schemes:
7776
7877- *posix_prefix *: scheme for POSIX platforms like Linux or macOS. This is
7978 the default scheme used when Python or a component is installed.
80- - *posix_home *: scheme for POSIX platforms used when a *home * option is used
81- upon installation. This scheme is used when a component is installed through
82- Distutils with a specific home prefix.
83- - *posix_user *: scheme for POSIX platforms used when a component is installed
84- through Distutils and the *user * option is used. This scheme defines paths
85- located under the user home directory.
79+ - *posix_home *: scheme for POSIX platforms, when the *home * option is used.
80+ This scheme defines paths located under a specific home prefix.
81+ - *posix_user *: scheme for POSIX platforms, when the *user * option is used.
82+ This scheme defines paths located under the user's home directory
83+ (:const: `site.USER_BASE `).
8684- *posix_venv *: scheme for :mod: `Python virtual environments <venv> ` on POSIX
8785 platforms; by default it is the same as *posix_prefix *.
88- - *nt *: scheme for NT platforms like Windows.
89- - *nt_user *: scheme for NT platforms, when the *user * option is used.
90- - *nt_venv *: scheme for :mod: `Python virtual environments <venv> ` on NT
91- platforms; by default it is the same as *nt *.
86+ - *nt *: scheme for Windows.
87+ This is the default scheme used when Python or a component is installed.
88+ - *nt_user *: scheme for Windows, when the *user * option is used.
89+ - *nt_venv *: scheme for :mod: `Python virtual environments <venv> ` on Windows;
90+ by default it is the same as *nt *.
9291- *venv *: a scheme with values from either *posix_venv * or *nt_venv * depending
9392 on the platform Python runs on.
9493- *osx_framework_user *: scheme for macOS, when the *user * option is used.
@@ -101,15 +100,165 @@ identifier. Python currently uses eight paths:
101100- *platstdlib *: directory containing the standard Python library files that are
102101 platform-specific.
103102- *platlib *: directory for site-specific, platform-specific files.
104- - *purelib *: directory for site-specific, non-platform-specific files.
103+ - *purelib *: directory for site-specific, non-platform-specific files ('pure' Python) .
105104- *include *: directory for non-platform-specific header files for
106105 the Python C-API.
107106- *platinclude *: directory for platform-specific header files for
108107 the Python C-API.
109108- *scripts *: directory for script files.
110109- *data *: directory for data files.
111110
112- :mod: `sysconfig ` provides some functions to determine these paths.
111+
112+ .. _sysconfig-user-scheme :
113+
114+ User scheme
115+ ---------------
116+
117+ This scheme is designed to be the most convenient solution for users that don't
118+ have write permission to the global site-packages directory or don't want to
119+ install into it.
120+
121+ Files will be installed into subdirectories of :const: `site.USER_BASE ` (written
122+ as :file: `{ userbase } ` hereafter). This scheme installs pure Python modules and
123+ extension modules in the same location (also known as :const: `site.USER_SITE `).
124+
125+ ``posix_user ``
126+ ^^^^^^^^^^^^^^
127+
128+ ============== ===========================================================
129+ Path Installation directory
130+ ============== ===========================================================
131+ *stdlib * :file: `{ userbase } /lib/python{ X.Y } `
132+ *platstdlib * :file: `{ userbase } /lib/python{ X.Y } `
133+ *platlib * :file: `{ userbase } /lib/python{ X.Y } /site-packages `
134+ *purelib * :file: `{ userbase } /lib/python{ X.Y } /site-packages `
135+ *include * :file: `{ userbase } /include/python{ X.Y } `
136+ *scripts * :file: `{ userbase } /bin `
137+ *data * :file: `{ userbase } `
138+ ============== ===========================================================
139+
140+ ``nt_user ``
141+ ^^^^^^^^^^^
142+
143+ ============== ===========================================================
144+ Path Installation directory
145+ ============== ===========================================================
146+ *stdlib * :file: `{ userbase } \\ Python{ XY } `
147+ *platstdlib * :file: `{ userbase } \\ Python{ XY } `
148+ *platlib * :file: `{ userbase } \\ Python{ XY } \\ site-packages `
149+ *purelib * :file: `{ userbase } \\ Python{ XY } \\ site-packages `
150+ *include * :file: `{ userbase } \\ Python{ XY } \\ Include `
151+ *scripts * :file: `{ userbase } \\ Python{ XY } \\ Scripts `
152+ *data * :file: `{ userbase } `
153+ ============== ===========================================================
154+
155+ ``osx_framework_user ``
156+ ^^^^^^^^^^^^^^^^^^^^^^
157+
158+ ============== ===========================================================
159+ Path Installation directory
160+ ============== ===========================================================
161+ *stdlib * :file: `{ userbase } /lib/python `
162+ *platstdlib * :file: `{ userbase } /lib/python `
163+ *platlib * :file: `{ userbase } /lib/python/site-packages `
164+ *purelib * :file: `{ userbase } /lib/python/site-packages `
165+ *include * :file: `{ userbase } /include/python{ X.Y } `
166+ *scripts * :file: `{ userbase } /bin `
167+ *data * :file: `{ userbase } `
168+ ============== ===========================================================
169+
170+
171+ .. _sysconfig-home-scheme :
172+
173+ Home scheme
174+ -----------
175+
176+ The idea behind the "home scheme" is that you build and maintain a personal
177+ stash of Python modules. This scheme's name is derived from the idea of a
178+ "home" directory on Unix, since it's not unusual for a Unix user to make their
179+ home directory have a layout similar to :file: `/usr/ ` or :file: `/usr/local/ `.
180+ This scheme can be used by anyone, regardless of the operating system they
181+ are installing for.
182+
183+ ``posix_home ``
184+ ^^^^^^^^^^^^^^
185+
186+ ============== ===========================================================
187+ Path Installation directory
188+ ============== ===========================================================
189+ *stdlib * :file: `{ home } /lib/python `
190+ *platstdlib * :file: `{ home } /lib/python `
191+ *platlib * :file: `{ home } /lib/python `
192+ *purelib * :file: `{ home } /lib/python `
193+ *include * :file: `{ home } /include/python `
194+ *platinclude * :file: `{ home } /include/python `
195+ *scripts * :file: `{ home } /bin `
196+ *data * :file: `{ home } `
197+ ============== ===========================================================
198+
199+
200+ .. _sysconfig-prefix-scheme :
201+
202+ Prefix scheme
203+ -------------
204+
205+ The "prefix scheme" is useful when you wish to use one Python installation to
206+ perform the build/install (i.e., to run the setup script), but install modules
207+ into the third-party module directory of a different Python installation (or
208+ something that looks like a different Python installation). If this sounds a
209+ trifle unusual, it is---that's why the user and home schemes come before. However,
210+ there are at least two known cases where the prefix scheme will be useful.
211+
212+ First, consider that many Linux distributions put Python in :file: `/usr `, rather
213+ than the more traditional :file: `/usr/local `. This is entirely appropriate,
214+ since in those cases Python is part of "the system" rather than a local add-on.
215+ However, if you are installing Python modules from source, you probably want
216+ them to go in :file: `/usr/local/lib/python2.{ X } ` rather than
217+ :file: `/usr/lib/python2.{ X } `.
218+
219+ Another possibility is a network filesystem where the name used to write to a
220+ remote directory is different from the name used to read it: for example, the
221+ Python interpreter accessed as :file: `/usr/local/bin/python ` might search for
222+ modules in :file: `/usr/local/lib/python2.{ X } `, but those modules would have to
223+ be installed to, say, :file: `/mnt/{ @server } /export/lib/python2.{ X } `.
224+
225+ ``posix_prefix ``
226+ ^^^^^^^^^^^^^^^^
227+
228+ ============== ==========================================================
229+ Path Installation directory
230+ ============== ==========================================================
231+ *stdlib * :file: `{ prefix } /lib/python{ X.Y } `
232+ *platstdlib * :file: `{ prefix } /lib/python{ X.Y } `
233+ *platlib * :file: `{ prefix } /lib/python{ X.Y } /site-packages `
234+ *purelib * :file: `{ prefix } /lib/python{ X.Y } /site-packages `
235+ *include * :file: `{ prefix } /include/python{ X.Y } `
236+ *platinclude * :file: `{ prefix } /include/python{ X.Y } `
237+ *scripts * :file: `{ prefix } /bin `
238+ *data * :file: `{ prefix } `
239+ ============== ==========================================================
240+
241+ ``nt ``
242+ ^^^^^^
243+
244+ ============== ==========================================================
245+ Path Installation directory
246+ ============== ==========================================================
247+ *stdlib * :file: `{ prefix } \\ Lib `
248+ *platstdlib * :file: `{ prefix } \\ Lib `
249+ *platlib * :file: `{ prefix } \\ Lib\\ site-packages `
250+ *purelib * :file: `{ prefix } \\ Lib\\ site-packages `
251+ *include * :file: `{ prefix } \\ Include `
252+ *platinclude * :file: `{ prefix } \\ Include `
253+ *scripts * :file: `{ prefix } \\ Scripts `
254+ *data * :file: `{ prefix } `
255+ ============== ==========================================================
256+
257+
258+ Installation path functions
259+ ---------------------------
260+
261+ :mod: `sysconfig ` provides some functions to determine these installation paths.
113262
114263.. function :: get_scheme_names()
115264
0 commit comments