site not automatically imported when using external python package #31507

Closed
opened 2012-05-17 22:33:00 +02:00 by Benoit Bolsee · 3 comments
Member

%%%Since blender is using Python 3.2, it does not import site automatically anymore. While this is probably acceptable when using the bundled python package (because the bundled package is not registered at system level and thus its site-packages directory is not visible to external installers), this is not justified if the bundle python package is not present: blender looks in this case for a system Python package, which, if it exists, is properly setup to import site. Not importing site means that external packages that might have been installed by the user will not be visible from python scripts.

The reason why site is not imported is explained in the code:

source/blender/python/intern/bpy_interface.c:
/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
* parse from the 'sysconfig' module which is used by 'site',
* so for now disable site. alternatively we could copy the file. */
Py_NoSiteFlag = 1;

The attached patch (author: Sjoerd de Vries) fixes this problem: Py_NoSiteFlag is not set when the bundle python package is not found to give a change%%%

%%%Since blender is using Python 3.2, it does not import site automatically anymore. While this is probably acceptable when using the bundled python package (because the bundled package is not registered at system level and thus its site-packages directory is not visible to external installers), this is not justified if the bundle python package is not present: blender looks in this case for a system Python package, which, if it exists, is properly setup to import site. Not importing site means that external packages that might have been installed by the user will not be visible from python scripts. The reason why site is not imported is explained in the code: source/blender/python/intern/bpy_interface.c: /* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to * parse from the 'sysconfig' module which is used by 'site', * so for now disable site. alternatively we could copy the file. */ Py_NoSiteFlag = 1; The attached patch (author: Sjoerd de Vries) fixes this problem: Py_NoSiteFlag is not set when the bundle python package is not found to give a change%%%
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'

%%%committed r46766. with some minor changes.%%%

%%%committed r46766. with some minor changes.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#31507
No description provided.