bug 1481612 - Add more actions to virtualenv_packages.txt and use them to include the unpacked Windows psutil wheel. r=gps
authorTed Mielczarek <ted@mielczarek.org>
Wed, 10 Oct 2018 19:53:47 +0000
changeset 440609 ec133330b1ec04135b786d0d3dc9a2fe4460d874
parent 440608 7243432584616e49d01a0b8910518b359d5aab99
child 440610 f5c1a7734493d3cf9e1ded5731bba0528b01155f
push id34827
push usertoros@mozilla.com
push dateThu, 11 Oct 2018 03:53:09 +0000
treeherdermozilla-central@b89a744deccb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1481612
milestone64.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 1481612 - Add more actions to virtualenv_packages.txt and use them to include the unpacked Windows psutil wheel. r=gps This patch adds two new actions to virtualenv_packages.txt processing: windows and !windows. The former processes the rest of the action only on Windows, and the latter processes it only on non-Windows. These new features are used in virtualenv_packages.txt to use the path to the unpacked Windows psutil wheel when on Windows, and build psutil from source and use that path on other platforms. This fixes the long-standing problem of not having psutil available on most Windows systems (since they don't have the right set of Visual C++ build tools). Differential Revision: https://phabricator.services.mozilla.com/D3437
build/mach_bootstrap.py
build/virtualenv_packages.txt
python/mozbuild/mozbuild/virtualenv.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -127,16 +127,23 @@ def search_path(mozilla_dir, packages_tx
     def handle_package(package):
         if package[0] == 'optional':
             try:
                 for path in handle_package(package[1:]):
                     yield path
             except Exception:
                 pass
 
+        if package[0] in ('windows', '!windows'):
+            for_win = not package[0].startswith('!')
+            is_win = sys.platform == 'win32'
+            if is_win == for_win:
+                for path in handle_package(package[1:]):
+                    yield path
+
         if package[0] == 'packages.txt':
             assert len(package) == 2
             for p in search_path(mozilla_dir, package[1]):
                 yield os.path.join(mozilla_dir, p)
 
         if package[0].endswith('.pth'):
             assert len(package) == 2
             yield os.path.join(mozilla_dir, package[1])
--- a/build/virtualenv_packages.txt
+++ b/build/virtualenv_packages.txt
@@ -17,18 +17,19 @@ mozilla.pth:third_party/python/dlmanager
 mozilla.pth:third_party/python/fluent
 mozilla.pth:third_party/python/funcsigs
 mozilla.pth:third_party/python/futures
 mozilla.pth:third_party/python/more-itertools
 mozilla.pth:third_party/python/gyp/pylib
 mozilla.pth:third_party/python/python-hglib
 mozilla.pth:third_party/python/pluggy
 mozilla.pth:third_party/python/jsmin
-optional:setup.py:third_party/python/psutil:build_ext:--inplace
-mozilla.pth:third_party/python/psutil
+!windows:optional:setup.py:third_party/python/psutil:build_ext:--inplace
+!windows:mozilla.pth:third_party/python/psutil
+windows:mozilla.pth:third_party/python/psutil-cp27-none-win_amd64
 mozilla.pth:third_party/python/pylru
 mozilla.pth:third_party/python/which
 mozilla.pth:third_party/python/pystache
 mozilla.pth:third_party/python/pyyaml/lib
 mozilla.pth:third_party/python/requests
 mozilla.pth:third_party/python/requests-unixsocket
 mozilla.pth:third_party/python/scandir
 mozilla.pth:third_party/python/slugid
--- a/python/mozbuild/mozbuild/virtualenv.py
+++ b/python/mozbuild/mozbuild/virtualenv.py
@@ -249,16 +249,22 @@ class VirtualenvManager(object):
         packages.txt -- Denotes that the specified path is a child manifest. It
             will be read and processed as if its contents were concatenated
             into the manifest being read.
 
         objdir -- Denotes a relative path in the object directory to add to the
             search path. e.g. "objdir:build" will add $topobjdir/build to the
             search path.
 
+        windows -- This denotes that the action should only be taken when run
+            on Windows.
+
+        !windows -- This denotes that the action should only be taken when run
+            on non-Windows systems.
+
         Note that the Python interpreter running this function should be the
         one from the virtualenv. If it is the system Python or if the
         environment is not configured properly, packages could be installed
         into the wrong place. This is how virtualenv's work.
         """
         packages = self.packages()
         python_lib = distutils.sysconfig.get_python_lib()
 
@@ -318,16 +324,23 @@ class VirtualenvManager(object):
                     handle_package(package[1:])
                     return True
                 except:
                     print('Error processing command. Ignoring', \
                         'because optional. (%s)' % ':'.join(package),
                         file=self.log_handle)
                     return False
 
+            if package[0] in ('windows', '!windows'):
+                for_win = not package[0].startswith('!')
+                is_win = sys.platform == 'win32'
+                if is_win == for_win:
+                    handle_package(package[1:])
+                return True
+
             if package[0] == 'objdir':
                 assert len(package) == 2
                 path = os.path.join(self.topobjdir, package[1])
 
                 with open(os.path.join(python_lib, 'objdir.pth'), 'a') as f:
                     f.write('%s\n' % path)
 
                 return True