Pushing Python to Windows workstations

Peter Hansen peter at engcorp.com
Mon May 5 14:31:52 EDT 2003


C42 wrote:
> Peter Hansen wrote:
> > C42 wrote:
> >>I need to install Python and win32all to all of the PCs on my
> >>Windows domain (100+). 
> >
> > Can you consider not installing it on all machines, but running from a
> > network install?
> 
> Can you tell me more about how you accomplished this? I have often
> wondered if there was a way to have Python run from a network share.

Well, first step is to install everything you need to a single machine,
in the usual way.  That's necessary even for extension modules because
many installers *insist* on installing only into Python installations
that are listed in the registry.  Kind of a shame, since it would probably
be pretty easy to let a user enter a path to override, but for pretty
much everything is anal about this in the same way so it's just a fact of life.

After everything is installed, and tested :-), just do an XCOPY from
the c:\python22 (or whatever) folder to the network drive.  We have our
stuff under i:\sw\a\python for example...

Next step (in our case, probably not necessary in general) is to have a
single network folder where various batch files run: i:\sw\utils in our
case.  Here we have a "python.bat" file which does two things only:
 
  @echo off
  set pythonhome=i:\sw\a\python
  %pythonhome%\python %1 %2 %3 %4 %5 %6 %7 %8 %9

Yes, DOS batch files are ugly as sin, but it works adequately so long
as you don't have a zillion(*) command line options.  (* where zillion
is defined as "greater than nine...)

Now that handles the basic Python stuff.  Next step is win32all.  It
might look like everything is working fine at this point, but you may
be running on a machine where some DLL files were copied into the 
c:\windows folder.  If those are not present, not everything will work
as well.

Our solution was to use a sitecustomize.py file to ensure that pythoncom.dll
and pywintypes.dll are always imported at startup, and with a bit of code
that ensures they are found by loading them with imp.load_module() using
sys.exec_prefix as the path.

I don't entirely recall sure why this latter step is necessary, but I think
it was because some of the win32all stuff (like win32com) finding its own
location by looking at the path from which pythoncom and/or pywintypes were
loaded.  If they are loaded from some other location, win32com can't find
itself and barfs.

I can post the current script for doing this magic if someone is interested.
(Please be prepared to test once I post though... I'd hate to have this 
cruft stuck in the archives without it having been put through the ringer
by someone outside of my group.  What works for us might be a disaster for
someone else, a year down the road.)

-Peter




More information about the Python-list mailing list