473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Python on portable storage

Howdy all,

I'm experimenting with carrying my personal computing environment around
on a keychain USB flash storage device. I have the usual suspects on
there: SSH keys, GPG keys, program configs.

I'm probably not the first to think that a standalone distribution of
Python would be a useful thing to have in my back pocket. Finding
information on that is proving to be a problem, however.

Can anyone provide pointers to how to go about this? My goals are:

- Carry a working Python >= 2.3 on the thing (must).
- Be able to run it on GNU/Linux systems from the device (must).
- Be able to run it on Win32 systems from the device (maybe).
- Refer to one copy of the standard library, regardless of how many
instances of the python executable (must).
- Ease of updating when future Python releases come out (maybe).

--
\ "Time's fun when you're having flies." -- Kermit the Frog |
`\ |
_o__) |
Ben Finney <http://bignose.squidly.org/>
Jul 18 '05 #1
5 1971
On 27 Jan 2004 12:59:26 +1050, Ben Finney wrote:
Howdy all,

I'm experimenting with carrying my personal computing environment around
on a keychain USB flash storage device. I have the usual suspects on
there: SSH keys, GPG keys, program configs.

I'm probably not the first to think that a standalone distribution of
Python would be a useful thing to have in my back pocket. Finding
information on that is proving to be a problem, however.


I did find this thread:

<http://groups.google.com/groups?group=comp.lang.python&threadm=VXcVa.28%24H Y3.42617%40news.uswest.net>

where the OP asked much the same question; the responses were mostly
"boot GNU/Linux and run it that way". This isn't what I'm after; I want
to walk up to an existing machine, and, without rebooting or installing
any software on the machine, plug in my USB storage device and run
Python entirely from that.

This will mean having a Python executable that can run under the
existing environment, of course. What I'm hoping is that there is
information on how to set that up, so that the resulting storage has a
self-contained Python environment, assuming the executable will run in
the first place.

--
\ "I filled my humidifier with wax. Now my room is all shiny." |
`\ -- Steven Wright |
_o__) |
Ben Finney <http://bignose.squidly.org/>
Jul 18 '05 #2
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.

Jeff

Jul 18 '05 #3
I forgot to mention that you should refer to the documentation to find
out about using .zip files to store .py/.pyc modules. This will have a
fairly dramatic effect on the amount of space needed to store the
standard library.

Jeff

Jul 18 '05 #4
On Mon, 26 Jan 2004 21:34:56 -0600, Jeff Epler wrote:
One idea would be a directory structure that looks like the source
tree: [...]


Thanks for this idea. I probably won't get the time to implement it for
a while, but when I do at least this gives an idea for where to start.

--
\ "A free society is one where it is safe to be unpopular." -- |
`\ Adlai Stevenson |
_o__) |
Ben Finney <http://bignose.squidly.org/>
Jul 18 '05 #5
"Jeff Epler" <je****@unpythonic.net> wrote in message
news:ma**************************************@pyth on.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
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David McNab | last post by:
Hi, I'm looking for adventurous pre-alpha testers for a DHTML (active website) framework for Python I've developed. Name: - pyWeb Features:
0
by: Irmen de Jong | last post by:
QOTW: "To make the instructions even friendlier it would also help if 'but Whatever You Do DON'T UNZIP THE FREAKIN' THING - This Means YOU John Latter!' were in large, bold, and underlined type. ...
5
by: Leif K-Brooks | last post by:
I'm writing a relatively simple multi-user public Web application with Python. It's a rewrite of a similar application which used PHP+MySQL (not particularly clean code, either). My opinions on...
9
by: CptDondo | last post by:
I am working on an embedded platform which has a block of battery-backed RAM. I need to store various types of data in this block of memory - for example, bitmapped data for control registers,...
852
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
37
by: Michele Simionato | last post by:
At work we are shopping for a Web framework, so I have been looking at the available options on the current market. In particular I have looked at Paste and Pylons and I have written my...
0
by: rkmr.em | last post by:
the memory usage of a python app keeps growing in a x86 64 linux continuously, whereas in 32 bit linux this is not the case. Python version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 Python...
2
by: Brian Vanderburg II | last post by:
I've installed Python 2.5 on MSW and it works. I'm preparing it to run from a thumb drive so I can run applications by dropping them onto the python.exe or from command line/etc. It works but the...
1
by: luismi | last post by:
Hi, I have searched the online manuals, faqs and forums, but i haven't found a satisfactory explanation ... most probably my fault ;) I have found 2 projects, one commercial and another free,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.