bug 1481612 - Add more actions to virtualenv_packages.txt and use them to include the unpacked Windows psutil wheel. r=gps
☠☠ backed out by 641b4a378923 ☠ ☠
authorTed Mielczarek <ted@mielczarek.org>
Wed, 15 Aug 2018 15:47:15 -0400
changeset 498957 de7e35a459e30fd5f68e0f1d085f67ec1bef3a88
parent 498956 eb440bc9fed13e4ad4a1fe2ab1a1ed445b269300
child 498958 857fb59a720e8f04e5d4f6ba60d4c9428f459751
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [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
@@ -16,18 +16,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/slugid
 mozilla.pth:third_party/python/py
--- 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