Controlling load location of python22.dll when using Py_Initialize()
Howard Lightstone
howard at eegsoftware.com
Wed Feb 19 01:41:10 EST 2003
quadric at primenet.com wrote in
news:mailman.1045629967.20368.python-list at python.org:
> Hi,
>
> I have embedded Python in an application and would like to control the
> location from
> whence the application loads python22.dll upon calling
> Py_Initialize(). I don't want to
> rely on the PATH variable as Python is already installed on this
> machine and I want the
> application to load the application specific version of python22.dll.
> I have tried using
> PYTHONPATH and PYTHONHOME but to no avail. It seems that the
> applications directory
> and directories along the PATH are the only ones searched.
>
> I have traced through the source for Py_Initialize() and it seems that
> the Windows Registry
> is searched for certain keys and the directories along the PATH. I am
> not opposed to using
> the applications directory but would prefer to control the load
> location myself.
>
> Can someone tell me how to tell Py_Initialize() where to look for
> python22.dll?
>
Since you have embedded it...
Before calling Py_Initialize(), add this code
strcpy(local,"PATH=MY_LOCATIONS_FOR_DLLS_AND_SUCH;")
strcat(local,getenv("PATH"));
putenv(local)
(no checking for buffer overflows.....bad bad bad)
Now, it will look first in YOUR locations for DLL files to load.
More information about the Python-list
mailing list