Auto merge of #24575 - marmeladema:issue-23607/compat, r=SimonSapin

Enable some mach commands to be run with python3

This change finally enable the following commands to be run with python3:
* `build`
* `test-unit`
* `package`

As previously explained, `test-tidy` will require more work in the wpt repository directly. Maybe `test-tidy --no-wpt` is achievable relatively quickly though.

For possible remaining bits that might need to be worked on, see https://github.com/servo/servo/issues/23607

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2019-12-10 16:34:10 -05:00 committed by GitHub
commit 8d4cedb911
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 30 deletions

View file

@ -27,6 +27,7 @@ import six
import sys
import tarfile
import zipfile
import functools
from xml.etree.ElementTree import XML
from servo.util import download_file
import six.moves.urllib as urllib
@ -103,15 +104,15 @@ def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None):
# Sort file entries with the fixed locale
with setlocale('C'):
file_list.sort(cmp=locale.strcoll)
file_list.sort(key=functools.cmp_to_key(locale.strcoll))
# Use a temporary file and atomic rename to avoid partially-formed
# packaging (in case of exceptional situations like running out of disk space).
# TODO do this in a temporary folder after #11983 is fixed
temp_file = '{}.temp~'.format(dest_archive)
with os.fdopen(os.open(temp_file, os.O_WRONLY | os.O_CREAT, 0o644), 'w') as out_file:
with os.fdopen(os.open(temp_file, os.O_WRONLY | os.O_CREAT, 0o644), 'wb') as out_file:
if dest_archive.endswith('.zip'):
with zipfile.ZipFile(temp_file, 'w', zipfile.ZIP_DEFLATED) as zip_file:
with zipfile.ZipFile(out_file, 'w', zipfile.ZIP_DEFLATED) as zip_file:
for entry in file_list:
arcname = entry
if prepend_path is not None:
@ -257,7 +258,7 @@ def gstreamer_root(target, env, topdir=None):
return env.get(gst_env)
elif os.path.exists(path.join(gst_default_path, "bin", "ffi-7.dll")):
return gst_default_path
elif sys.platform == "linux2":
elif is_linux():
return path.join(topdir, "support", "linux", "gstreamer", "gst")
return None
@ -579,7 +580,7 @@ class CommandBase(object):
if "x86_64" not in effective_target or "android" in effective_target:
# We don't build gstreamer for non-x86_64 / android yet
return False
if sys.platform == "linux2" or is_windows():
if is_linux() or is_windows():
if path.isdir(gstreamer_root(effective_target, env, self.get_top_dir())):
return True
else:
@ -689,7 +690,7 @@ install them, let us know by filing a bug!")
extra_lib = [libpath] + extra_lib
append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH")
if sys.platform == "linux2":
if is_linux():
distrib, version, _ = distro.linux_distribution()
distrib = six.ensure_str(distrib)
version = six.ensure_str(version)