Bug 31533 - webkitpy __init__.py (webkit-patch) should detect python < 2.5 and show a nice error message
Summary: webkitpy __init__.py (webkit-patch) should detect python < 2.5 and show a nic...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Chris Jerdonek
URL:
Keywords:
Depends on: 35788 35828
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-16 01:31 PST by Eric Seidel (no email)
Modified: 2010-03-13 16:24 PST (History)
7 users (show)

See Also:


Attachments
Proposed patch (11.20 KB, patch)
2010-03-07 17:07 PST, Chris Jerdonek
abarth: review+
cjerdonek: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2009-11-16 01:31:34 PST
bugzilla-tool should detect python < 2.5 and show a nice error message

Google has this screwy config where "python" maps to python 2.4 instead of python 2.5 on the corp image.  Presumably this will go away when we migrate to snow leopard, but for now everyone who tries bugzilla-tool on a google mac gets an ugly parse error.

We could fix this via:
1.  Using a different #! line, like: "#!/usr/bin/env python2.5"
2.  Detecting python < 2.5 (or missing ternary operators) and show a nice error message, including even something about how to fix your Google mac. :)
3.  Some other nifty hack.
Comment 1 Tony Chang 2009-11-16 10:04:26 PST
Would it be hard to just support python2.4?  I don't really like python's ternary syntax anyway.

If you want to detect version, you can use sys.version_info.
Comment 2 Mark Rowe (bdash) 2009-11-16 11:37:07 PST
Solution 1 isn’t a good idea since it’ll break for folks that only have Python > 2.5.
Comment 3 Eric Seidel (no email) 2009-11-16 14:44:48 PST
I'm not sure how difficult it would be support 2.4.  I'd have to check what other features we depend on.
Comment 4 Chris Jerdonek 2010-01-26 20:45:22 PST
For future reference, here is a case of code breaking with Python 2.5:

https://bugs.webkit.org/show_bug.cgi?id=33365#c9

Maybe test-webkitpy should issue a warning if run using Python 2.6+.
Comment 5 Chris Jerdonek 2010-03-07 17:07:35 PST
Created attachment 50180 [details]
Proposed patch

I didn't add any information about how to upgrade.  Perhaps we can simply include a link to this wiki page, and include instructions there:

http://trac.webkit.org/wiki/PythonGuidelines

Let me know your preference.

Also, note that pending patches in the following two reports are required for this patch to work:

https://bugs.webkit.org/show_bug.cgi?id=35828
https://bugs.webkit.org/show_bug.cgi?id=35788

So the style bot may not work.  Also marking cq- for that reason.
Comment 6 Adam Barth 2010-03-13 02:23:11 PST
Comment on attachment 50180 [details]
Proposed patch

I'm not wild about the name "patcher.py".

We've discussed the issue of python version requirements a bunch.  I'm not 100% sure what the final resolution was, but this patch is just making the code print a nicer error message.  If we want to support older versions of Python, we can still do that.
Comment 7 Chris Jerdonek 2010-03-13 16:05:14 PST
(In reply to comment #6)
> (From update of attachment 50180 [details])
> I'm not wild about the name "patcher.py".

Agreed.  We can rename in a later patch.  I mainly wanted to choose something without "webkit" in the name since it's redundant with being in webkitpy.

Naming the main lead-in file for a package main.py might be a good way to go.  But that didn't quite seem to fit here since the module does more than expose a main method -- it defines a substantive class.

> We've discussed the issue of python version requirements a bunch.  I'm not 100%
> sure what the final resolution was, but this patch is just making the code
> print a nicer error message.  If we want to support older versions of Python,
> we can still do that.

Exactly.  Hopefully we'll get clarification on that soon.  I might prod the list again on Monday -- this time with an attempted summary.
Comment 8 Chris Jerdonek 2010-03-13 16:24:35 PST
Manually committed (via git svn dcommit):

http://trac.webkit.org/changeset/55972