Use python without install it.

Markku Hänninen hmm at iki.fi
Sun Aug 4 17:36:16 EDT 2002


Chris Liechti <cliechti at gmx.net> writes:

> "Bertrand Geston" <bergeston at yahoo.fr> wrote in
> news:ai917o$12j0d8$1 at ID-135695.news.dfncis.de: 
> > Does somebody know if it is possible to use python on a computer under
> > Linux on that it's not allowed to install it for security reasons
> > (server in production) ?
> > The purpose is to have some shell scripts written in Python to make
> > some maintenance tasks. Those scripts are launched manually.
> 
> McMillan's Installer http://www.mcmillan-inc.com/install1.html
> has linux support.
> Freeze should work too, but i think that's not that easy to use.

I have created a tool for software installation purposes which is basically a
single-file python interpreter using freeze. The reason for this is, that 
installation shell-scripts grow far too complicated and hard to maintain but 
we can't rely on having python in the customers machines (and having python
installation in our installation procedure would be too complicated and 
could propaby lead into "political" issues described above). 

This is the freezed script:

#!/usr/bin/env python
#
# (C) 2002 Markku Hänninen (hmm at iki.fi)
#

# add here all python-modules that are used in the scripts
# which are run with this utility
import sys, os

# if we have arguments, assume that the first argument is a python program
# and the rest are arguments for it, otherwise run the interactive interpreter
sys.argv=sys.argv[1:]
if len(sys.argv):
    execfile(sys.argv[0])
else:
    code.interact()


Creating the tool:

        1. link python statically 

        2. check that you have added all the needed modules to the script

        3. run freeze for the script

You can then run your programs by running "spython <program>" assuming that
you use the same name for the script as I did, spython (for static python).

I have created a short description of this at:
http://www.iki.fi/~hmm/python/spython.html

The problem with this is of course that the programs run with this are limited
to the module-set defined before freezing. However, that's not so much of a
problem if you know that all of them will be also produced by you. (And if 
you're using this for installation, you can then make a python-program that
installs full python for you :-)

I also recently tried using McMillan's installer instead of freeze and it
seemed to work slightly better (I could include xml.dom to the interpreter,
which with freeze seems a bit difficult). With that you can also omit
static linking of python (but I rather stick to it, as I don't like the 
dynamic libraries appearing to the directory at runtime).


> try to convince the admin of that machine. python is _very_ stable. your 
> scripts will be better maintainable in python as well as faster developed. 
> that should be enough resons to install it and save money ;-)

It usually seems to be very hard to require customers install any additional
software, it seems to be better to include everything as part of your 
"product".


-- 
   Markku Hänninen     /
     hmm at iki.fi       /   "Actually it works, it just doesn't look that way." 



More information about the Python-list mailing list