* [PATCH] make build-many-glibcs.py work on python3.2
@ 2016-11-22 13:51 Szabolcs Nagy
2016-11-22 17:25 ` Joseph Myers
0 siblings, 1 reply; 6+ messages in thread
From: Szabolcs Nagy @ 2016-11-22 13:51 UTC (permalink / raw)
To: GNU C Library; +Cc: nd
[-- Attachment #1: Type: text/plain, Size: 355 bytes --]
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).
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.
[-- Attachment #2: a.diff --]
[-- Type: text/x-patch, Size: 1406 bytes --]
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 517dec4..b928dee 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -40,6 +40,42 @@ import subprocess
import sys
import urllib.request
+try:
+ os.cpu_count
+except:
+ os.cpu_count = lambda: 1
+
+try:
+ re.fullmatch
+except:
+ re.fullmatch = lambda p,s,f=0: re.match("^"+p+"$",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."""
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make build-many-glibcs.py work on python3.2
2016-11-22 13:51 [PATCH] make build-many-glibcs.py work on python3.2 Szabolcs Nagy
@ 2016-11-22 17:25 ` Joseph Myers
0 siblings, 0 replies; 6+ messages in thread
From: Joseph Myers @ 2016-11-22 17:25 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: GNU C Library, nd
On Tue, 22 Nov 2016, Szabolcs Nagy wrote:
> +try:
> + os.cpu_count
> +except:
> + os.cpu_count = lambda: 1
multiprocessing.cpu_count may be a better fallback.
> +try:
> + re.fullmatch
> +except:
> + re.fullmatch = lambda p,s,f=0: re.match("^"+p+"$",s,f)
You don't need the ^ since match means match at the start of the string.
And \Z corresponds more accurately to fullmatch semantics than $.
(I think the principle of including such compatibility code is fine if
people want to use the script with older Python 3.x. I don't have
anything older than 3.4 (the version on Ubuntu 14.04) to hand for testing
such compatibility code myself.)
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Make build-many-glibcs.py work on python3.2
2017-01-10 20:12 [PATCH] Make " Adhemerval Zanella
2017-01-10 21:57 ` Joseph Myers
2017-01-11 10:37 ` Florian Weimer
@ 2017-01-11 12:33 ` Szabolcs Nagy
2 siblings, 0 replies; 6+ messages in thread
From: Szabolcs Nagy @ 2017-01-11 12:33 UTC (permalink / raw)
To: Adhemerval Zanella, libc-alpha; +Cc: nd
On 10/01/17 20:11, Adhemerval Zanella wrote:
> This is an updated version based on Joseph's review [1] with comments
> fixed.
thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Make build-many-glibcs.py work on python3.2
2017-01-10 20:12 [PATCH] Make " Adhemerval Zanella
2017-01-10 21:57 ` Joseph Myers
@ 2017-01-11 10:37 ` Florian Weimer
2017-01-11 12:33 ` Szabolcs Nagy
2 siblings, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2017-01-11 10:37 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Szabolcs Nagy
* Adhemerval Zanella:
> + re.fullmatch = lambda p,s,f=0: re.match(p+"\Z",s,f)
Please use: p + r"\Z" or p + "\\Z"
I'm surprised "\Z" isn't a syntax error.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Make build-many-glibcs.py work on python3.2
2017-01-10 20:12 [PATCH] Make " Adhemerval Zanella
@ 2017-01-10 21:57 ` Joseph Myers
2017-01-11 10:37 ` Florian Weimer
2017-01-11 12:33 ` Szabolcs Nagy
2 siblings, 0 replies; 6+ messages in thread
From: Joseph Myers @ 2017-01-10 21:57 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, Szabolcs Nagy
On Tue, 10 Jan 2017, Adhemerval Zanella wrote:
> 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.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Make build-many-glibcs.py work on python3.2
@ 2017-01-10 20:12 Adhemerval Zanella
2017-01-10 21:57 ` Joseph Myers
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Adhemerval Zanella @ 2017-01-10 20:12 UTC (permalink / raw)
To: libc-alpha; +Cc: Szabolcs Nagy
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-11 12:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 13:51 [PATCH] make build-many-glibcs.py work on python3.2 Szabolcs Nagy
2016-11-22 17:25 ` Joseph Myers
2017-01-10 20:12 [PATCH] Make " Adhemerval Zanella
2017-01-10 21:57 ` Joseph Myers
2017-01-11 10:37 ` Florian Weimer
2017-01-11 12:33 ` Szabolcs Nagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).