Unify python interpreter abstractions (#178)

Previously, we had two python interpreter metadata structs, one in
gourgeist and one in puffin. Both would spawn a subprocess to query
overlapping metadata and both would appear in the cli crate, if you
weren't careful you could even have to different base interpreters at
once. This change unifies this to one set of metadata, queried and
cached once.

Another effect of this crate is proper separation of python interpreter
and venv. A base interpreter (such as `/usr/bin/python/`, but also pyenv
and conda installed python) has a set of metadata. A venv has a root and
inherits the base python metadata except for `sys.prefix`, which unlike
`sys.base_prefix`, gets set to the venv root. From the root and the
interpreter info we can compute the paths inside the venv. We can reuse
the interpreter info of the base interpreter when creating a venv
without having to query the newly created `python`.
This commit is contained in:
konsti 2023-10-25 22:11:36 +02:00 committed by GitHub
parent 1fbe328257
commit 889f6173cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 515 additions and 584 deletions

View file

@ -16,11 +16,7 @@ def main():
output = check_output(["bash"], input=command, text=True).strip()
assert output.startswith("usage:"), output
output = (
check_output([venv_python, "imasnake.py"], text=True)
.strip()
.splitlines()
)
output = check_output([venv_python, "imasnake.py"], text=True).strip().splitlines()
assert output[0] == str(project_root.joinpath(venv_python)), output
assert not output[2].startswith(str(project_root)), output
assert output[3] == str(project_root.joinpath(venv_name)), output