Patch to allow mozrunner to work on python < 2.5

VERIFIED FIXED

Status

VERIFIED FIXED
8 years ago
8 years ago

People

(Reporter: zcerza, Assigned: zcerza)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [mozmill-1.5.1+])

Attachments

(1 attachment)

(Assignee)

Description

8 years ago
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
(Assignee)

Comment 1

8 years ago
Created attachment 482342 [details] [diff] [review]
patch
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 3

8 years ago
Comment on attachment 482342 [details] [diff] [review]
patch

Flipping review to our python package guru jhammel
Attachment #482342 - Flags: review?(ctalbert) → review?(jhammel)

Comment 4

8 years ago
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-
(Assignee)

Comment 5

8 years ago
Ah, of course. Good catch Jeff.

Updated

8 years ago
Whiteboard: [mozmill-1.5.1?] → [mozmill-1.5.1+]

Updated

8 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 8 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+]
(Assignee)

Comment 9

8 years ago
(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
Depends on: 608289
You need to log in before you can comment on or make changes to this bug.