This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Make build-many-glibcs.py work on python3.2
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Cc: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Date: Tue, 10 Jan 2017 18:11:57 -0200
- Subject: [PATCH] Make build-many-glibcs.py work on python3.2
- Authentication-results: sourceware.org; auth=none
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
This is an updated version based on Joseph's review [1] with comments
fixed.
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
(ubuntu 12.04).
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.
[1] https://sourceware.org/ml/libc-alpha/2016-11/msg00799.html
---
ChangeLog | 5 +++++
scripts/build-many-glibcs.py | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index ce632d7..e39b9f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-10 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
+ (re.fullmatch, subprocess.run): Likewise.
+
2016-01-10 Siddhesh Poyarekar <siddhesh@sourceware.org>
* elf/dl-tunables.c (tunables_unsetenv): Remove function.
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 60a7874..61d2121 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -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."""
--
2.7.4