]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Make build-many-glibcs.py work on python3.2
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 10 Jan 2017 18:31:19 +0000 (16:31 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 11 Jan 2017 12:30:40 +0000 (10:30 -0200)
I used this patch to run the new build script with python3.2, it may be worth
adding this hack if python3.5 is not widespread (might work with older python,
i haven't tested that).

This patch make build-many-glibcs.py work with python 3.2 by
adding fallback implementation to python 3.5 facilities if they
are not present.

Checked building a x86_64-linux-gnu toolchain with python 3.2.

2016-11-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

* scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
(re.fullmatch, subprocess.run): Likewise.

ChangeLog
scripts/build-many-glibcs.py

index e1cb0378f6fc8bf6ff1a53493a7ba538498a79e7..4f87985cdbaa8749b3512a7481118e14fe513f3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+       * scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
+       (re.fullmatch, subprocess.run): Likewise.
+
 2016-01-11  Siddhesh Poyarekar  <siddhesh@sourceware.org>
 
        * po/libc.pot: Regenerate.
index 60a78748753d4a50387fd720a07750d394fa875a..d27e70b8bdcf06c0ac6eb79a8acabdafc0d3dd5d 100755 (executable)
@@ -49,6 +49,43 @@ import sys
 import time
 import urllib.request
 
+try:
+    os.cpu_count
+except:
+    import multiprocessing
+    os.cpu_count = lambda: multiprocessing.cpu_count()
+
+try:
+    re.fullmatch
+except:
+    re.fullmatch = lambda p,s,f=0: re.match(p+"\\Z",s,f)
+
+try:
+    subprocess.run
+except:
+    class _CompletedProcess:
+        def __init__(self, args, returncode, stdout=None, stderr=None):
+            self.args = args
+            self.returncode = returncode
+            self.stdout = stdout
+            self.stderr = stderr
+
+    def _run(*popenargs, input=None, timeout=None, check=False, **kwargs):
+        assert(timeout is None)
+        with subprocess.Popen(*popenargs, **kwargs) as process:
+            try:
+                stdout, stderr = process.communicate(input)
+            except:
+                process.kill()
+                process.wait()
+                raise
+            returncode = process.poll()
+            if check and returncode:
+                raise subprocess.CalledProcessError(returncode, popenargs)
+        return _CompletedProcess(popenargs, returncode, stdout, stderr)
+
+    subprocess.run = _run
+
 
 class Context(object):
     """The global state associated with builds in a given directory."""