Closed Bug 603461 Opened 14 years ago Closed 14 years ago

Patch to allow mozrunner to work on python < 2.5

Categories

(Testing :: Mozbase, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: zcerza, Assigned: zcerza)

References

Details

(Whiteboard: [mozmill-1.5.1+])

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.467.0 Safari/534.3
Build Identifier: 

While trying to run mozmill on RHEL5, I ran across the following:

Traceback (most recent call last):
File "/usr/bin/mozmill", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 277, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2180, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1913, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/mozmill-1.5.0-py2.4.egg/mozmill/__init__.py", line 61, in ?
import jsbridge
File "/usr/lib/python2.4/site-packages/jsbridge-2.4.0-py2.4.egg/jsbridge/__init__.py", line 48, in ?
import mozrunner
File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 50, in ?

ImportError: No module named etree


Oddly, the traceback is pretty useless. I did find the problem - xml.etree only showed up in python 2.5. But, the elementtree was available separately before that. Here's a patch that will support both.

Reproducible: Always
Attached patch patchSplinter Review
Comment on attachment 482342 [details] [diff] [review]
patch

Officially we do not support Python versions below 2.5. But if that's really such a simple change, why we shouldn't? Thanks for the patch Zack! I will set the review request to Clint, who is one of the drivers of the tool. Lets see what he thinks.
Attachment #482342 - Flags: review?(ctalbert)
Assignee: nobody → zcerza
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Whiteboard: [mozmill-1.5.1?]
Comment on attachment 482342 [details] [diff] [review]
patch

Flipping review to our python package guru jhammel
Attachment #482342 - Flags: review?(ctalbert) → review?(jhammel)
Comment on attachment 482342 [details] [diff] [review]
patch

this won't work unless elementtree is already installed.  As such, it should be added to the dependencies:

diff --git a/mozrunner/mozrunner/__init__.py b/mozrunner/mozrunner/__init__.py
index 9e726f6..e2c75a9 100644
--- a/mozrunner/mozrunner/__init__.py
+++ b/mozrunner/mozrunner/__init__.py
@@ -52,6 +52,11 @@ from xml.etree import ElementTree
 from distutils import dir_util
 from time import sleep
 
+# conditional (version-dependent) imports
+try:
+    from xml.etree import ElementTree
+except ImportError:
+    from elementtree import ElementTree
 try:
     import simplejson
 except ImportError:
diff --git a/mozrunner/setup.py b/mozrunner/setup.py
index c922c53..bef01ca 100644
--- a/mozrunner/setup.py
+++ b/mozrunner/setup.py
@@ -46,8 +46,14 @@ PACKAGE_VERSION = "2.5.1"
 
 deps = []
 
-if not sys.version.startswith('2.6'):
+# we only support python 2 right now
+assert sys.version_info[0] == 2
+
+# version-dependent dependencies
+if not sys.version_info[1] < 6:
     deps.append('simplejson')
+if not sys.version_info[1] < 5:
+    deps.append('elementtree')
 
 setup(name=PACKAGE_NAME,
       version=PACKAGE_VERSION,
Attachment #482342 - Flags: review?(jhammel) → review-
Ah, of course. Good catch Jeff.
Whiteboard: [mozmill-1.5.1?] → [mozmill-1.5.1+]
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [mozmill-1.5.1+] → [mozmill-1.5.1+][needs-landing-2.0]
Zack, does the RC1 build work for you? If yes, can you please mark this bug as verified? Thanks.
Landed on master:
http://github.com/mozautomation/mozmill/commit/456e50bbc3fe4ad24f76f4375471ecd109045225
Whiteboard: [mozmill-1.5.1+][needs-landing-2.0] → [mozmill-1.5.1+]
(In reply to comment #7)
> Zack, does the RC1 build work for you? If yes, can you please mark this bug as
> verified? Thanks.

It does fix the problem I was having. I am having some issues with jsbridge not working, though... I'll have to investigate that and see if I can fix it. Thanks!
Thanks for you feedback. Additional fixes are now outside of the scope for Mozmill 1.5.1. You will at least have to wait for 1.5.2.

Marking bug as verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: