[Tutor] Tutorial executable from python script.
lie.1296 at gmail.com
Sun Mar 21 09:19:17 CET 2010
On 03/21/2010 06:00 AM, Karim Liateni wrote:
> Hello Alan,
> In fact, I want to be sure the users can run it on every machine in our
> Especially, I want to be able to run it on Solaris 5.8 with python 1.5
> (Unix machine).
> I wanted to know if I could make some custom executable like in C when
> you want
> to build a executable with a static library to be sure if the system
> does not have
> the correct shares libraries.
If you know that the machine contains `python` (whatever the version is)
you can use sys.version to check the system python's version. It can be
as simple as:
if int(sys.version) > 1 or
(int(sys.version) == 1 and int(sys.version >= 5)):
# or you can start a subprocess instead,
# abusing import makes "if __name__ == '__main__':" magic not work
# parentheses guards for python 3
print ('script is only compatible with python version 1.5 and above')
Otherwise, if you cannot even rely on python being available, you may
need to use shell script.
> Perhaps the better is to build a python version embedded in my
> application installation.
> Do you have any examples or tutorial on how integrate python inside a
> pplication to be
> sure that we have all in one and not depand on any local machine
> installation environment.
> I need as to embed gtk python library for graphical use.
That is indeed possible, however is there any reason why the server
don't upgrade its python version? CPython makes it easy to do parallel
installation of two different python version. If you can persuade the
machine administrator to install python2.6 as an altinstall; you can
simply change the hashbang line of your script to "#!/usr/bin/env
python2.6" and all is well.
More information about the Tutor