[Bf-blender-cvs] [72c012ab4a3] master: Python: enable user site-packages without --python-use-system-env

Campbell Barton noreply at git.blender.org
Wed Jan 25 02:52:59 CET 2023


Commit: 72c012ab4a3d2a7f7f59334f4912402338c82e3c
Author: Campbell Barton
Date:   Wed Jan 25 12:41:59 2023 +1100
Branches: master
https://developer.blender.org/rB72c012ab4a3d2a7f7f59334f4912402338c82e3c

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.

===================================================================

M	source/blender/python/intern/bpy_interface.c

===================================================================

diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index a83dc464e43..8f112c14bb2 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -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;



More information about the Bf-blender-cvs mailing list