Bug 1189847 - [mozversion] mozversion requires mozdevice, it shoudn't. r=dhunt
authorJulien Pagès <j.parkouss@gmail.com>
Mon, 03 Aug 2015 06:32:00 +0200
changeset 287751 95e44c9c8457d4b313400192bb9a43483e62026e
parent 287750 2053b3d500ab9cd913a2d34ba152337dc49dd117
child 287752 3f700e2cebbcc625c2f2aa6d6d857609e8afd8be
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhunt
bugs1189847
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1189847 - [mozversion] mozversion requires mozdevice, it shoudn't. r=dhunt This make the mozdevice dependency of mozversion optional.
testing/mozbase/docs/mozversion.rst
testing/mozbase/mozversion/mozversion/mozversion.py
testing/mozbase/mozversion/setup.py
--- a/testing/mozbase/docs/mozversion.rst
+++ b/testing/mozbase/docs/mozversion.rst
@@ -1,16 +1,25 @@
 :mod:`mozversion` --- Get application information
 =================================================
 
 `mozversion <https://github.com/mozilla/mozbase/tree/master/mozversion>`_
 provides version information such as the application name and the changesets
 that it has been built from. This is commonly used in reporting or for
 conditional logic based on the application under test.
 
+Note that mozversion can report the version of remote devices (e.g. Firefox OS)
+but it requires the :mod:`mozdevice` dependency in that case. You can require it
+along with mozversion by using the extra *device* dependency:
+
+.. code-block:: bash
+
+  pip install mozversion[device]
+
+
 API Usage
 ---------
 
 .. automodule:: mozversion
     :members: get_version
 
 Examples
 ````````
--- a/testing/mozbase/mozversion/mozversion/mozversion.py
+++ b/testing/mozbase/mozversion/mozversion/mozversion.py
@@ -7,17 +7,16 @@ import ConfigParser
 from StringIO import StringIO
 import os
 import re
 import sys
 import tempfile
 import xml.dom.minidom
 import zipfile
 
-import mozdevice
 import mozfile
 import mozlog
 
 import errors
 
 
 INI_DATA_MAPPING = (('application', 'App'), ('platform', 'Build'))
 
@@ -184,16 +183,23 @@ class LocalB2GVersion(B2GVersion):
 
 class RemoteB2GVersion(B2GVersion):
 
     def __init__(self, sources=None, dm_type='adb', host=None,
                  device_serial=None, adb_host=None, adb_port=None,
                  **kwargs):
         B2GVersion.__init__(self, sources, **kwargs)
 
+        try:
+            import mozdevice
+        except ImportError:
+            self._logger.critical("mozdevice is required to get the version"
+                                  " of a remote device")
+            raise
+
         if dm_type == 'adb':
             dm = mozdevice.DeviceManagerADB(deviceSerial=device_serial,
                                             serverHost=adb_host,
                                             serverPort=adb_port)
         elif dm_type == 'sut':
             if not host:
                 raise errors.RemoteAppNotFoundError(
                     'A host for SUT must be supplied.')
--- a/testing/mozbase/mozversion/setup.py
+++ b/testing/mozbase/mozversion/setup.py
@@ -1,31 +1,29 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from setuptools import setup
 
 PACKAGE_VERSION = '1.3'
 
-dependencies = ['mozdevice >= 0.44',
-                'mozfile >= 1.0',
-                'mozlog >= 3.0']
 
 setup(name='mozversion',
       version=PACKAGE_VERSION,
       description='Library to get version information for applications',
       long_description='See http://mozbase.readthedocs.org',
       classifiers=[],
       keywords='mozilla',
       author='Mozilla Automation and Testing Team',
       author_email='tools@lists.mozilla.org',
       url='https://wiki.mozilla.org/Auto-tools/Projects/Mozbase',
       license='MPL',
       packages=['mozversion'],
       include_package_data=True,
       zip_safe=False,
-      install_requires=dependencies,
+      install_requires=['mozfile >= 1.0', 'mozlog >= 3.0'],
+      extras_require={'device': ['mozdevice >= 0.44']},
       entry_points="""
       # -*- Entry points: -*-
       [console_scripts]
       mozversion = mozversion:cli
       """)