Bug 1486899 - Do not use virtualenv_options.append('--always-copy') on Redhat derived distros, r=jlund,ahal.
authorBob Clary <bclary@bclary.com>
Sun, 02 Sep 2018 08:08:46 -0700
changeset 489566 766ddd82a829064d4dc62c1178140e39136fb931
parent 489565 7f63a3e0614789ff83efd539a4395ee809d4af59
child 489567 634b562ae2c3af1c07e12cca895796cc501f343d
push id9738
push useraciure@mozilla.com
push dateMon, 03 Sep 2018 16:13:51 +0000
treeherdermozilla-beta@f5841408a66c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlund, ahal
bugs1486899
milestone63.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 1486899 - Do not use virtualenv_options.append('--always-copy') on Redhat derived distros, r=jlund,ahal.
testing/mozharness/mozharness/base/python.py
testing/mozharness/mozharness/base/script.py
--- a/testing/mozharness/mozharness/base/python.py
+++ b/testing/mozharness/mozharness/base/python.py
@@ -344,19 +344,27 @@ class VirtualenvMixin(object):
         # Always use the virtualenv that is vendored since that is deterministic.
         # TODO Bug 1408051 - Use the copy of virtualenv under
         # third_party/python/virtualenv once everything is off buildbot
         virtualenv = [
             sys.executable,
             os.path.join(external_tools_path, 'virtualenv', 'virtualenv.py'),
         ]
         virtualenv_options = c.get('virtualenv_options', [])
-        # Don't create symlinks. If we don't do this, permissions issues may
-        # hinder virtualenv creation or operation.
-        virtualenv_options.append('--always-copy')
+        # Creating symlinks in the virtualenv may cause issues during
+        # virtualenv creation or operation on non-Redhat derived
+        # distros. On Redhat derived distros --always-copy causes
+        # imports to fail. See
+        # https://github.com/pypa/virtualenv/issues/565. Therefore
+        # only use --alway-copy when not using Redhat.
+        if self._is_redhat():
+            self.warning("creating virtualenv without --always-copy "
+                         "due to issues on Redhat derived distros")
+        else:
+            virtualenv_options.append('--always-copy')
 
         if os.path.exists(self.query_python_path()):
             self.info("Virtualenv %s appears to already exist; skipping virtualenv creation." % self.query_python_path())
         else:
             self.mkdir_p(dirs['abs_work_dir'])
             self.run_command(virtualenv + virtualenv_options + [venv_path],
                              cwd=dirs['abs_work_dir'],
                              error_list=VirtualenvErrorList,
--- a/testing/mozharness/mozharness/base/script.py
+++ b/testing/mozharness/mozharness/base/script.py
@@ -49,16 +49,17 @@ if os.name == 'nt':
 try:
     import simplejson as json
     assert json
 except ImportError:
     import json
 
 from io import BytesIO
 
+import mozinfo
 from mozprocess import ProcessHandler
 from mozharness.base.config import BaseConfig
 from mozharness.base.log import SimpleFileLogger, MultiFileLogger, \
     LogMixin, OutputParser, DEBUG, INFO, ERROR, FATAL
 
 
 class ContentLengthMismatch(Exception):
     pass
@@ -113,16 +114,27 @@ class PlatformMixin(object):
         Returns:
             bool: True if the current platform is a Linux distro, False otherwise
         """
         if platform.system() in ("Linux"):
             return True
         if sys.platform.startswith("linux"):
             return True
 
+    def _is_redhat(self):
+        """ check if the current operating system is a Redhat derived Linux distribution.
+
+        Returns:
+            bool: True if the current platform is a Redhat Linux distro, False otherwise
+        """
+        if not self._is_linux():
+            return False
+        re_redhat_distro = re.compile('Redhat|Fedora|CentOS|Oracle')
+        return re_redhat_distro.match(mozinfo.linux_distro) is not None
+
     def _is_64_bit(self):
         if self._is_darwin():
             # osx is a special snowflake and to ensure the arch, it is better to use the following
             return sys.maxsize > 2**32  # context: https://docs.python.org/2/library/platform.html
         else:
             # Using machine() gives you the architecture of the host rather
             # than the build type of the Python binary
             return '64' in platform.machine()