473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1983
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.c om/groups?group=co mp.lang.python& threadm=VXcVa.2 8%24HY3.42617%4 0news.uswest.ne t>

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****@unpytho nic.net> wrote in message
news:ma******** *************** *************** @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:\py thon23\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
2058
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
1418
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. And preferably a different colour." -- John Latter, on Python's install instructions " What's more, these are three of Python's greatest *strengths*. We resist all attempts to change these, and we (at least I) avoid other languages because...
5
2176
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 various Web frameworks tends to vary with the phase of the moon, but currently, I'm planning to use Quixote. Needless to say, my application will need some kind of persistent data storage. The previous PHP+MySQL application uses around 1.1GB of...
9
2433
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, strings for logging, and structures for data points. I want to use one function to read data from this block and one function to write data, for example: sram_read(OBJECT_IDENTIFIER) would return a pointer to the appriate object and
852
28326
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 my general education. Mark
37
2559
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 impressions here: http://www.phyast.pitt.edu/~micheles/python/yet-another-comparison-of-web-frameworks.html I do not speak too well of Pylons, so if you thing I am wrong feel free to correct me here ;)
0
1175
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.5.1 (r251:54863, Oct 30 2007, 13:45:26) i isolated the memory leak problem to a function that uses datetime module extensively. i use datetime.datetime.strptime, datetime.timedelta, datetime.datetime.now methods... i tried to get some info...
2
1078
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 size is quite large. I've compressed most of the executables with UPX even the dlls under site-packages, but is there a way I could compress the top-level 'lib' directory into a python.zip instead so save some space, and do I need the 'test'...
1
1301
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, that deal with the installation and running of python code on portable/removable devices, my questions are: (1) Is this scenario not yet contemplated in the official releases, and
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.