Python: enable user site-packages without --python-use-system-env

User site-packages were disabled unless `--python-use-system-env`
argument was given. This was done to prevent Blender's Python
unintentionally using modules that happened to be installed locally,
however it meant so pip installing modules from Blender would fail to
load those modules (for some users).

Enable user site-packages since it's needed for installing additional
packages via pip, see code-comments for details.

Resolves T104000.
This commit is contained in:
2023-01-25 12:41:59 +11:00
parent 7416021bf7
commit 72c012ab4a

View File

@@ -371,8 +371,14 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
* While harmless, it's noisy. */
config.pathconfig_warnings = 0;
/* When using the system's Python, allow the site-directory as well. */
config.user_site_directory = py_use_system_env;
/* Allow the user site directory because this is used
* when PIP installing packages from Blender, see: T104000.
*
* NOTE(@campbellbarton): While an argument can be made for isolating Blender's Python
* from the users home directory entirely, an alternative directory should be used in that
* case - so PIP can be used to install packages. Otherwise PIP will install packages to a
* directory which us not in the users `sys.path`, see `site.USER_BASE` for details. */
// config.user_site_directory = py_use_system_env;
/* While `sys.argv` is set, we don't want Python to interpret it. */
config.parse_argv = 0;