Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43976: add vendor config #25718

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Doc/library/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ 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}/site-packages` (on Unix and macOS), and finally
the ``purelib`` and ``platlib`` paths for each scheme specified in the
``EXTRA_SITE_INSTALL_SCHEMES`` list variable of the vendor config. 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.

.. versionchanged:: 3.5
Support for the "site-python" directory has been removed.

.. versionchanged:: 3.11
Extra site install schemes specified in the vendor config
(``--with-vendor-config`` configure option) will also be loaded.

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
Expand Down
19 changes: 4 additions & 15 deletions Doc/library/sysconfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ Python currently supports seven schemes:
- *nt*: scheme for NT platforms like Windows.
- *nt_user*: scheme for NT platforms, when the *user* option is used.

Additionally to these, Python also supports vendor schemes specified in the
``EXTRA_INSTALL_SCHEMES`` dictionary variable of the vendor config
(``--with-vendor-config`` configure option).

Each scheme is itself composed of a series of paths and each path has a unique
identifier. Python currently uses eight paths:

Expand Down Expand Up @@ -129,21 +133,6 @@ identifier. Python currently uses eight paths:
.. versionadded:: 3.10


.. function:: _get_preferred_schemes()

Return a dict containing preferred scheme names on the current platform.
Python implementers and redistributors may add their preferred schemes to
the ``_INSTALL_SCHEMES`` module-level global value, and modify this function
to return those scheme names, to e.g. provide different schemes for system
and language package managers to use, so packages installed by either do not
mix with those by the other.

End users should not use this function, but :func:`get_default_scheme` and
:func:`get_preferred_scheme()` instead.

.. versionadded:: 3.10


.. function:: get_path_names()

Return a tuple containing all path names currently supported in
Expand Down
26 changes: 26 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,32 @@ General Options

.. versionadded:: 3.10

.. cmdoption:: --with-vendor-config=config.py

Path to the vendor config (none by default).

The vendor config is a Python file that allows configuring some aspects of
the Python distribution.

A ``EXTRA_INSTALL_SCHEMES`` dictionary variable can be specified in the
config to add extra install schemes. These schemes will be picked up by the
:mod:`sysconfig` module.

A ``EXTRA_SITE_INSTALL_SCHEMES`` list variable can be specified in the config
to add extra schemes to the :mod:`site` module initialization. This options
allow Python distributors to define custom locations to use for their Python
packages.

A ``get_preferred_schemes()`` function can be specified in the config. This
function should return a dict containing preferred scheme names on the
current platform. Python implementers and redistributors may add their
preferred schemes to the ``EXTRA_INSTALL_SCHEMES`` vendor config variable,
and modify this function to return those scheme names, to e.g. provide
different schemes for system and language package managers to use, so
packages installed by either do not mix with those by the other.

.. versionadded:: 3.11


Install Options
---------------
Expand Down
Loading