Bug 1231981 - Part 5: Install python packages we need in the virtualenv if not present. r=gps
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 16 Mar 2016 15:40:17 -0500
changeset 294933 5b8583070c9ea1d28305e5d41c9f841048f47bd0
parent 294932 2942bb31152c2bd0a79b381aef727ab6930c52ec
child 294934 baa6c68ec41333ffc90107a3343fe38e0c060f99
push id75734
push userbcampen@mozilla.com
push dateTue, 26 Apr 2016 15:02:20 +0000
treeherdermozilla-inbound@baa6c68ec413 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1231981
milestone49.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 1231981 - Part 5: Install python packages we need in the virtualenv if not present. r=gps MozReview-Commit-ID: 9PUHLMxHhQP
python/mozbuild/mozbuild/virtualenv.py
testing/mochitest/mach_commands.py
testing/mochitest/runtests.py
--- a/python/mozbuild/mozbuild/virtualenv.py
+++ b/python/mozbuild/mozbuild/virtualenv.py
@@ -457,16 +457,27 @@ class VirtualenvManager(object):
         virtualenv, you can simply instantiate an instance of this class
         and call .ensure() and .activate() to make the virtualenv active.
         """
 
         execfile(self.activate_path, dict(__file__=self.activate_path))
         if isinstance(os.environ['PATH'], unicode):
             os.environ['PATH'] = os.environ['PATH'].encode('utf-8')
 
+    def install_pip_requirements_file(self, requirements_filename):
+        """Installs packages in |requirements_filename| via pip."""
+
+        args = [
+            'install',
+            '-r',
+            requirements_filename
+        ]
+
+        return self._run_pip(args)
+
     def install_pip_package(self, package):
         """Install a package via pip.
 
         The supplied package is specified using a pip requirement specifier.
         e.g. 'foo' or 'foo==1.0'.
 
         If the package is already installed, this is a no-op.
         """
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -150,16 +150,22 @@ class MochitestRunner(MozbuildObject):
 
         self.tests_dir = os.path.join(self.topobjdir, '_tests')
         self.mochitest_dir = os.path.join(
             self.tests_dir,
             'testing',
             'mochitest')
         self.bin_dir = os.path.join(self.topobjdir, 'dist', 'bin')
 
+        self._activate_virtualenv()
+        self.virtualenv_manager.install_pip_requirements_file(
+                os.path.join(self.mochitest_dir,
+                             'websocketprocessbridge',
+                             'websocketprocessbridge_requirements.txt'))
+
     def resolve_tests(self, test_paths, test_objects=None, cwd=None):
         if test_objects:
             return test_objects
 
         from mozbuild.testing import TestResolver
         resolver = self._spawn(TestResolver)
         tests = list(resolver.resolve_tests(paths=test_paths, cwd=cwd))
         return tests
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -810,16 +810,17 @@ class MochitestBase(object):
     def startWebsocketProcessBridge(self, options):
         """Create a websocket server that can launch various processes that
         JS needs (eg; ICE server for webrtc testing)
         """
 
         command = [sys.executable,
                    os.path.join("websocketprocessbridge",
                                 "websocketprocessbridge.py")]
+        os.environ['PYTHONPATH'] = os.pathsep.join(p for p in sys.path)
         self.websocketprocessbridge = mozprocess.ProcessHandler(command,
                                                                 cwd=SCRIPT_DIR)
         self.websocketprocessbridge.run()
         self.log.info("runtests.py | websocket/process bridge pid: %d"
                       % self.websocketprocessbridge.pid)
 
         # ensure the server is up, wait for at most ten seconds
         for i in range(1,100):