Python on portable storage

Paul Paterson paulpaterson at users.sourceforge.net
Wed Jan 28 02:05:13 EST 2004


"Jeff Epler" <jepler at unpythonic.net> wrote in message
news:mailman.832.1075174501.12720.python-list at python.org...
> One idea would be a directory structure that looks like the source tree:
>
> python23/python         # linux executable
> python23/python.exe     # windows executable
> python23/Lib            # shared version of /usr/lib/python2.3
> python23/Lib/site.py    # modify this to add any extra tweaks needed for
>                         # things to work properly (it's loaded very early)
> python23/Lib/plat-linux # linux shared-object modules
> python23/Lib/plat-win32 # win32 shared-object modules
>
> In this setup, you are assuming some set of Linux shared objects, use
> ldd to find out which.  (A script setting LD_LIBRARY_PATH to point at
> necessary libraries before calling python could help here)
>
> If you want to support multiple Unix architectures, make python a
> shell script, and include multiple python.ARCH binaries.  Have the shell
> script determine the architecture, and then exec python.ARCH with
> arguments intact.  This should not affect the way Python determines the
> default sys.path.
>
> I don't know much about windows .dll requirements or how to resolve
> problems there.

I can't add to the Linux part but I have Python23 installed on a USB
keychain drive to run on Windows alone. I just installed using the standard
Windows installer into a Python23 directory on the USB drive. You also need
to make sure Python23.dll ends up in the Python23 directory, probably by
manually copying it. Then to get it all to work properly I have a little
batch file in the root of the USB drive with the following,

---- setup.bat ----
echo Setting Path
path =
%1:\python23;%1\python23\lib;%1:\python23\lib\site-packages;%1:\python23\dll
s
set pythonpath = %1:\python23
---- end ----

When you mount the USB drive you open a command prompt and CD to the root of
the USB and type "setup X" where X is the drive letter assigned to the USB
drive. You can now run Python by just typing "python" at the command prompt.

This works for me. You have to be a bit careful if you already have Python
installed on the machine as sometimes sys.path includes parts of the
existing installation even after you run the batch file. I think this might
be something to do with stuff in the registry.

Hope this helps. It is cool to keep a Python in your pocket.

Paul





More information about the Python-list mailing list