Re: [Python-Dev] r85028 - in python/branches/py3k: Doc/c-api/init.rst Include/pythonrun.h Modules/getpath.c PC/getpathp.c
Am 27.09.2010 07:32, schrieb kristjan.jonsson:
Author: kristjan.jonsson Date: Mon Sep 27 07:32:54 2010 New Revision: 85028
Log: issue 9910 Add a Py_SetPath api to override magic path computations when starting up python.
Modified: python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Include/pythonrun.h python/branches/py3k/Modules/getpath.c python/branches/py3k/PC/getpathp.c
Modified: python/branches/py3k/Doc/c-api/init.rst
+.. cfunction:: void Py_SetPath(const wchar_t *) + + .. index:: + triple: module; search; path + single: path (in module sys) + single: Py_GetPath() + + Set the default module search path. If this function is called before + :cfunc: `Py_Initialize` then :cfunc: Py_GetPath won't attempt to compute + a default serarch path but uses the provided one in stead. This is useful + if Python is being embedded by an application that has full knowledge + of the location of all modules. The path components should be separated + by semicolons. + + This also causes `sys.executable` to be set only to the raw program name + (see :cfunc:`Py_SetProgramName`) and `for sys.prefix` and + `sys.exec_prefix` to be empty. It is up to the caller to modify these if + required after calling :cfunc: `Py_Initialize`. +
This needs a versionadded. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
On 27 September 2010 11:57, Georg Brandl
Am 27.09.2010 07:32, schrieb kristjan.jonsson:
Author: kristjan.jonsson Date: Mon Sep 27 07:32:54 2010 New Revision: 85028
Log: issue 9910 Add a Py_SetPath api to override magic path computations when starting up python.
Modified: python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Include/pythonrun.h python/branches/py3k/Modules/getpath.c python/branches/py3k/PC/getpathp.c
Modified: python/branches/py3k/Doc/c-api/init.rst
+.. cfunction:: void Py_SetPath(const wchar_t *) + + .. index:: + triple: module; search; path + single: path (in module sys) + single: Py_GetPath() + + Set the default module search path. If this function is called before + :cfunc: `Py_Initialize` then :cfunc: Py_GetPath won't attempt to compute + a default serarch path but uses the provided one in stead. This is useful + if Python is being embedded by an application that has full knowledge + of the location of all modules. The path components should be separated + by semicolons. + + This also causes `sys.executable` to be set only to the raw program name + (see :cfunc:`Py_SetProgramName`) and `for sys.prefix` and + `sys.exec_prefix` to be empty. It is up to the caller to modify these if + required after calling :cfunc: `Py_Initialize`. +
This needs a versionadded.
Georg
Did you noticed " ... The path components should be separated by semicolons." ? I would expect os.path.pathsep, after all paths are not OS-independent. -- Lisandro Dalcin --------------- CIMEC (INTEC/CONICET-UNL) Predio CONICET-Santa Fe Colectora RN 168 Km 472, Paraje El Pozo Tel: +54-342-4511594 (ext 1011) Tel/Fax: +54-342-4511169
On Thu, Sep 30, 2010 at 3:43 AM, Lisandro Dalcin
Did you noticed " ... The path components should be separated by semicolons." ? I would expect os.path.pathsep, after all paths are not OS-independent.
That's true when reading from PYTHONPATH. For a programmatic API like this, being consistent is probably simpler in most cases. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (3)
-
Georg Brandl
-
Lisandro Dalcin
-
Nick Coghlan