Dealing with python version

Andrei Kulakov ak at silmarill.org
Thu Mar 28 02:34:14 EST 2002


In article <m3u1r1y68i.fsf at wilma.localdomain>, Harry George wrote:
> Andrei Kulakov <ak at silmarill.org> writes:
> 
>> Hello,
>> 
>> Correct me if I'm wrong, but it seems like if python1.6 or 2.0 are
>> already installed and you install a newer version, python command still
>> points to the old interpreter.
>> 
>> I think it would be sensible to use the newest installed python to run
>> a program. Is there some elegant way to do that?
>> 
>> I would ideally prefer it to run using newest interpreter available
>> unless it's older than some minimum requirement. It's not very
>> user-friendly to put #!/usr/bin/env python2.1 bang line and then say in
>> a README that if user gets an error, he has to somehow find out what's
>> the latest version he's got and change the bang line to it.
>> 
>> What's the proper way to deal with all of this?
>> 
> 

[snip]

Umm.. I guess I should have made it more explicit that I'm distributing
an application - I have a tarfile on my website that people are supposed
to download, unarchive and run. The problem is that even if they have
a python version that could run it correctly, the program itself should
intelligently detect which versions are there, whether any of them is
good enough, and if not, tell the user what exactly is the problem.

What I had in mind is a function that'd take two arguments: minimum
python version that the program needs and the program name itself. I.e.
say I have a file called vtip.py that needs at least python 2.1. I'd
like a module that I can name run_vtip.py, and in it I'd have to set two
vars at top:

min_python_version = "2.1"
run = "vtip.py"

Then it'd look at what python versions are available and if there's one
that's equal or higher than 2.1, use it to run vtip.py, and if not, tell
user that vtip needs 2.1 and he should get that.

This seems like a very useful thing to do, and if you ask users to do
this manually in your README, some of them will either miss or
misunderstand it, then email you, and some will have trouble determining
what versions they have and how to change bang lines, etc.

IOW, this should be automated. Hadn't anyone done this yet? Is there
some particular reason why this is hard to implement?


 - Andrei


-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org



More information about the Python-list mailing list