From patchwork Tue Jan 10 20:11:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 90759 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp793331qgi; Tue, 10 Jan 2017 12:12:29 -0800 (PST) X-Received: by 10.84.216.70 with SMTP id f6mr7566733plj.10.1484079149334; Tue, 10 Jan 2017 12:12:29 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d9si3189699pge.193.2017.01.10.12.12.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 12:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-76669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76669-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=UrpzFioEH8lYoV+8sRnZmQJYiCqSOl2IHcsKGpmv5JzPYkeuBLoHy Gguu6KWtT8magMCJ314y2B0jzUizL1C5mR2d9oEtjOTyxKgA0+WMb1IHydceQiIf KstiWGV6r71ehsV7ZlVMtOMxJI32NCdac0LlYOz3wipSt7L/8woFRg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=avKM27DtkOVeGFGJmgqEOGzHuIo=; b=bYYK2VrV0w30ZgQU0B9yUKbPsx9w CcDhYTzWShVyZX3Uyyuoq0B3Ze3H30nYyTQgAsB5p/pNjvDrYN/PY2ke9Q+9Mor5 0Iq5qHZaNQsbqhEnHcZYd47d97BAwulx7pV8Bwj9F5koQY7O4R5sU/BjLXyBR0yz +PMWqA7xyeOyMLo= Received: (qmail 107056 invoked by alias); 10 Jan 2017 20:12:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 107041 invoked by uid 89); 10 Jan 2017 20:12:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=1204, siddheshsourcewareorg, siddhesh@sourceware.org, U*siddhesh X-HELO: mail-ua0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tToBC4FQdrPDCE6P+G1Nwfw/FXjJH8kh5RySO3EuDS0=; b=Ubfxa+oChxVNoRpoVsqNBgksrfAvCSw8mEu1jad8P3Te287rUz2E3ewEFc8AzRBcmS TH1a+hYMLPA2EmVq1AAep9PZq9sMq6oi/hVNj2Gl6o+HK6NedYuHcGNfPAdvvLnRdTMZ UqEPDtcCurdY/6esVjic+lnWx8ljfs/iu9z8XtyNLRAL2/MXaj2GPrRdHCFZdn09BOEU oigtdnWNb5AzgQr8D7GtAtEVqZhf8hmds4WWrqvjc3+QUbAhMQRSPgYJuOXWxlcZ1Tti ihosRfZdOFadO06O1V2oM0bA1C00ipYCLjmlj3aRs+eygc9W07TS/Ky2RReZF4oYEl17 EWwA== X-Gm-Message-State: AIkVDXLCYUQjXCzDQeIurBYY33WUZZVyQ+9HBjP9osVknQjTjiUMlvBiaBMuyyduKi/M9C+U X-Received: by 10.176.2.14 with SMTP id 14mr2727677uas.8.1484079124178; Tue, 10 Jan 2017 12:12:04 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Szabolcs Nagy Subject: [PATCH] Make build-many-glibcs.py work on python3.2 Date: Tue, 10 Jan 2017 18:11:57 -0200 Message-Id: <1484079117-17506-1-git-send-email-adhemerval.zanella@linaro.org> From: Szabolcs Nagy 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 * 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(+) -- 2.7.4 diff --git a/ChangeLog b/ChangeLog index ce632d7..e39b9f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-01-10 Szabolcs Nagy + + * scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition. + (re.fullmatch, subprocess.run): Likewise. + 2016-01-10 Siddhesh Poyarekar * 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."""