[New-bugs-announce] [issue9910] Add Py_SetPath API for embeddint python
Kristján Valur Jónsson
report at bugs.python.org
Tue Sep 21 08:32:34 CEST 2010
New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:
When calling Py_Initialize() from an embedding application, there is currently no way for the application to override Python's initial settin g of sys.path. An elaborate mechanism in getpathp.c kicks in, guessing the path based on several criteria.
Ideally, this mechanism, which is valid only for python.exe and its semantics, should be opt in. It forces embedders that have their own libraries to go through complicated hoops (with environment variables and what not) to direct their embedded interpreter at the right place for modules, and to make sure that it is not confused by any other python distribution present on the system.
This submission adds a Py_SetPath() function to the API. This has been successfully used by CCP in EVE Online and other products to completely override python's path guessing mechanics. If called with a semicolon separated path prior to Py_Initialize, it will be used as the fodder for the initial sys.path.
components: Interpreter Core
keywords: easy, needs review, patch
title: Add Py_SetPath API for embeddint python
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file18943/py_setpath.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce