[Python] How does creating a Python venv with `--system-site-packages` work under the hood?

Discussão em 'Python' iniciado por Stack, Dezembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to understand how creating a Python venv with access to the system site-packages work. The documentation doesn't go much into details, so I've just checked the diff between two venvs with and without the --system-site-packages option. It seems that the difference is just in pyvenv.cfg:

    @@ -1,5 +1,5 @@
    home = /usr/bin
    -include-system-site-packages = true
    +include-system-site-packages = false
    version = 3.12.8
    executable = /usr/bin/python3.12
    -command = /usr/bin/python -m venv --system-site-packages /tmp/venv1
    +command = /usr/bin/python -m venv /tmp/venv2


    How does this make the system packages accessible in the virtual environment?

    Continue reading...

Compartilhe esta Página