Skip to content

Instantly share code, notes, and snippets.

@luser
Created August 15, 2018 19:13
Show Gist options
  • Save luser/b38a26c4018da11c2adb036b3210c4c0 to your computer and use it in GitHub Desktop.
Save luser/b38a26c4018da11c2adb036b3210c4c0 to your computer and use it in GitHub Desktop.
diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.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] == 'windows' and sys.platform == 'win32':
+ for path in handle_package(package[1:]):
+ yield path
+ elif package[0] == '!windows' and sys.platform != 'win32':
+ 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])
diff --git a/build/virtualenv_packages.txt b/build/virtualenv_packages.txt
--- 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-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
diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment