[issue43976] Allow Python distributors to add custom site install schemes

Frederik Rietdijk report at bugs.python.org
Tue Jan 25 13:24:36 EST 2022


Frederik Rietdijk <fridh at fridh.nl> added the comment:

In Nixpkgs we install every Python package under a unique prefix, a so-called Nix store path. If we were to use sysconfig for installing packages, then we'd need to be able to dynamically set the paths. This was also discussed as part of the Installer project. https://github.com/pradyunsg/installer/issues/98

We could use a custom scheme, however, we do need to be able to dynamically set a certain variable, e.g. `base`.

```
variables = {"installed_base": "$out", "base": "$out", "platbase": "$out", "installed_platbase": "$out"}
# Note there is no `sysconfig.get_default_scheme()`
sysconfig._expand_vars("posix_prefix", variables)
```

I could imagine we do something like

```
# check whether we're in a nix build and want to install in a prefix
if "IN_NIX_BUILD" in os.environ:
    base = os.environ["out"]

    scheme = {...}
```
We'd then need to update the base variable in sysconfig or partially expand our own scheme using this variable.

----------
nosy: +Frederik Rietdijk

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43976>
_______________________________________


More information about the Python-bugs-list mailing list