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:
Campbell Barton 2023-01-25 12:41:59 +11:00
parent 7416021bf7
commit 72c012ab4a
Notes: blender-bot 2023-04-17 21:00:27 +02:00
Referenced by issue #104000, python site-packages are not recognized after install (bug on linux / workes fine on Windows)
Referenced by issue #106963, Blender not recognizing crc32c library in add-on
1 changed files with 8 additions and 2 deletions

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;