FAQ
I've embedded python into a C++ - windows app by a
PyImport_AppendInittab() + Py_Initialize() method.

Py_Initialize() calculates a module search path from the
windows-registry settings.

I want to prevent Python from doing that and want to hardwire the search
path to a app. relative path ("<app>/pythonmod") which points to a
minimal python bunch to avoid the need for installing python.

Does anybody know what to do prior to Py_Initialize(). Or am I
completely wrong?
PySys_SetPath() crashes when called before Py_Initialize().

Robert

Search Discussions

  • Warren Postma at Apr 7, 2000 at 1:18 pm

    Does anybody know what to do prior to Py_Initialize(). Or am I
    completely wrong?
    PySys_SetPath() crashes when called before Py_Initialize().
    First just set the environment variable PYTHONPATH, but if you want to have
    it ignore the registry on Windows, I think you may have to resort to
    modifying source code.

    I did this. Look for registry code in import_nt.c. Email me if you want to
    see what I did, but since they are trivial you can probably do it yourself.

    My modified version ignores the registry, uses the PYTHONPATH, as well as
    certain 'hardcoded' sensibiel defaults such as looking in the Lib
    subdirectory from wherever your program is running from for the 'site.py'
    and 'exceptions.py' modules. From there, set up your additional module
    search paths in the PYTHONPATH environment variable.

    Warren
  • Gordon McMillan at Apr 7, 2000 at 6:05 pm

    Robert Kiendl wrote:
    I've embedded python into a C++ - windows app by a
    PyImport_AppendInittab() + Py_Initialize() method.

    Py_Initialize() calculates a module search path from the
    windows-registry settings.

    I want to prevent Python from doing that and want to hardwire the search
    path to a app. relative path ("<app>/pythonmod") which points to a
    minimal python bunch to avoid the need for installing python.

    Does anybody know what to do prior to Py_Initialize(). Or am I
    completely wrong?
    PySys_SetPath() crashes when called before Py_Initialize().
    I suggest you just rewrite getpath.c to do what you want. It
    runs during Py_Initialize. Otherwise, you can undo what
    getpath.c does after Py_Initialize, but there's a hole there.

    - Gordon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 7, '00 at 12:57p
activeApr 7, '00 at 6:05p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase