win32 extension installation problem

zihonglu zihonglu at home.com
Sun Jun 24 19:45:09 EDT 2001


Mark,

Thanks for your reply.  I have tried changing the version in Python21.dll to
"MyPython21", changing registry version accordingly, and put the file back
to c:\winnt\system32 directory, manually put win32 extension files under the
python directory.  It worked.

However, since the Python21.dll has been changed, I wanted it to be located
in c:\MySoftware\Python to prevent being accidentally overwritten .  As far
as python is concerned, it seems to work fine.  I could register the
PythonService.exe as well.  However, I can't start my python service.  The
problem went away as soon as I put the modified Python21.dll back to the
system32 directory.  I vaguely remember I have the same problem with
PyWinTypes.dll. Any solution?


-Zihong

Mark Hammond <MarkH at ActiveState.com> wrote in message
news:3B355CE8.8060605 at ActiveState.com...
> zihonglu wrote:
>
> > We are building a product with python and the win32 extension, in win32
> > environment.  I have a problem in shipping the product with win32
extension.
> >
> > What I really want is to have the python interpreter and the win32
extension
> > installed inside our product's directory, say c:\MySoftware\Python, and
in
> > the registry, set python's keys under HKLM\Software\MySoftware\Python,
> > instead of the typical HKLM\Software\Python, to avoid conflict with
> > customer's possible existing python installation or possible future
python
> > installation change.  I can achieve that by change python's source code
to
> > look for the new registry key.
>
>
> The best solution is to change Python's view of the core registry key.
>
> The default Python registry key is
> HKLM\Software\Python\PythonCore\{version-id}
>
> This {version-id} is loaded from the Python.dll string resource table.
> You can open Python.dll in MSVC (ie, the pre-built version - no need to
> rebuild anything) and locate the one-and-only string resource. This will
> say, eg, "2.1". Hence the registry used for 2.1 is:
>
> HKLM\Software\Python\PythonCore\2.1
>
> You can change this to any value you like (numeric or otherwise). This
> will change the registry key used by that DLL. FYI, this value is
> reflected into Python as sys.winver - however, you can not simply change
> it at runtime, as the value has already been used by the time you get
> your first opportunity to change it.
>
> So, although you can not simply change the "root" of the registry,
> changing this version string will give you your own playground that will
> not affect pre-installed versions.
>
> > However, since I am also using the win32
> > extension, it looks HKLM/Software/Python for its installation and
execution,
> > not my new keys.  I also use PythonService.exe, which checks for its key
> > under HKLM/Software/Python for registering the service, not the one I
set
> > under my new keys.
>
>
> You probably don't want to use the win32all installer - simply install
> these extensions along with your software into the appropriate
directories.
>
> At runtime, there is nothing hard-coded to use the version number.
> pythonservice.exe and all other code that needs the registry at runtime
> uses sys.winver to determine where to put it.  Hence, pythonservice.exe
> running with a patched python.dll should magically do the right thing.
>
> This mechanism was added specifically for this situation, so you may as
> well use it.
>
>
> > To solve these problems, how many places I need to change the win32
> > extension source code, if I can find them?  Is there a better way?
Where do
> > I get the source code?
>
> You get the source code via
> http://starship.python.net/crew/mhammond/cvs.html
>
> Mark.
>





More information about the Python-list mailing list