From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#70722: [PATCH] ; Migrate to python3 for (package-test-update-archives-async) Date: Fri, 10 May 2024 01:00:13 +0900 Message-ID: References: <86sez0jb7i.fsf@gnu.org> <86bk5f75bv.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Fri_May_10_01:00:11_2024-1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4201"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: 70722@debbugs.gnu.org To: Eli Zaretskii , Lin Sun Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 09 18:02:21 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s56Ds-0000sk-Uv for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 May 2024 18:02:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s56Ci-0004gT-Ux; Thu, 09 May 2024 12:01:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s56CC-0004QR-Ml for bug-gnu-emacs@gnu.org; Thu, 09 May 2024 12:00:36 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s56CC-0000ZY-FP for bug-gnu-emacs@gnu.org; Thu, 09 May 2024 12:00:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s56Cc-0004kH-Gf for bug-gnu-emacs@gnu.org; Thu, 09 May 2024 12:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 May 2024 16:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70722 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70722-submit@debbugs.gnu.org id=B70722.171527045518226 (code B ref 70722); Thu, 09 May 2024 16:01:02 +0000 Original-Received: (at 70722) by debbugs.gnu.org; 9 May 2024 16:00:55 +0000 Original-Received: from localhost ([127.0.0.1]:56037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s56CU-0004ju-QT for submit@debbugs.gnu.org; Thu, 09 May 2024 12:00:55 -0400 Original-Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:50251) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s56CQ-0004jo-3G for 70722@debbugs.gnu.org; Thu, 09 May 2024 12:00:53 -0400 Original-Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6f4178aec15so970725b3a.0 for <70722@debbugs.gnu.org>; Thu, 09 May 2024 09:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715270418; x=1715875218; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=BQUTd7KSlza68eQrrGCP1afgr4W6WH5Il6UkvlPQEsM=; b=dKELGZ280NT3iZA/cmQeTBoTQqwcHIOh0aIFFZURP8zjzn8jgOOsLzGREmUJ+26aXP 8vId4aYk1/ZHdvgoPt6l2RDtV8cQB9modlsg+bdMkil2A5hpvQHK3eY3XQRZ3LmT80aT x7CAcoVtAxsc1ddcHo3Ia6zBMaJtEiUDxyxL6AM7JVKLQcGZxlTivneWAyrupoQP4hQu PicO+nH1pHwSfjv+CXeYcfoQ8V2HBTlUoePZ4CjU7I9G99APlpkoblDK3Wd1xYH6nIG0 arss4t5/bo4Et6PLqtSdBoqqm5yKnAom9sQCe2kV6ewiuMSec0v/AmHQtm/4IQvnHNIj L4OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715270418; x=1715875218; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BQUTd7KSlza68eQrrGCP1afgr4W6WH5Il6UkvlPQEsM=; b=Vo247Ec4SyvA8pxGeNgIcaee0DL3rcJ3U5UDKvi/jXFq5Ij6fAIqTZ1Kv1dAxuAmmr TtFqHEjdbg85MZcChpf3+VPIyNdNpSxNEAwe4XUQ2f8S0LPB5S7SHriX4fwXtzVnJuSl cYQ7M2xOWt1pLU6R4Pe2OKa/k8Yi4wgvgkI8ocXBu4+JnDF1A6EYTniMBu9soD6mp6T8 kqC2DThKoV2rnREYizFZmUMyjmIJNlUvQ4AtQWM1YH1kpln+88tCs7pqTOeeC4BhVWkK lN94mK/BwzGdui60ZJmKrcefqBjXb2SoBANjR7pO9AvSLQ0ytkAM41aCHdsfNrxffIZI Hjvw== X-Gm-Message-State: AOJu0YxSqAk1NZrCEOz+EOjOkus6ylY5bR/WLgtis/YdiWP58o7TB9wt bjhkCDWJ3t45dzlrffwmwbU7/Bitn0Zkutdm3dhi0EMnCDGkI269 X-Google-Smtp-Source: AGHT+IF++A/rhFz8senqCk1Obdwd/O66tyWyYt/tlNq1DLhVO3gxRTOcI9PsvxxD7JVhmTl0y9wOdA== X-Received: by 2002:a05:6a21:19c:b0:1af:a2fa:e666 with SMTP id adf61e73a8af0-1afde0b6e9emr198762637.10.1715270417728; Thu, 09 May 2024 09:00:17 -0700 (PDT) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c25683dsm15935535ad.299.2024.05.09.09.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 09:00:17 -0700 (PDT) In-Reply-To: <86bk5f75bv.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284761 Archived-At: --Multipart_Fri_May_10_01:00:11_2024-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: >=20 > > From: Lin Sun > > Date: Mon, 6 May 2024 00:28:07 +0000 > > Cc: 70722@debbugs.gnu.org > >=20 > > On Thu, May 2, 2024 at 6:55=E2=80=AFPM Eli Zaretskii wro= te: > > > > > > > From: Lin Sun > > > > Date: Thu, 2 May 2024 18:11:04 +0000 > > > > > > > > The test case "package-test-update-archives-async" still tries to > > > > search "python2" for testing, while python2 was at the end of its l= ife > > > > years ago. > > > > So move the test case from python2 to python3. > > > > > > I'd prefer to make the test support both Python 2.x and Python 3.x. > > > The fact that python.org end-of-life'd Python 2 doesn't mean we have > > > to jump to attention and follow suit. Old systems might still have > > > Python 2 installed, and there's no need to drop them. > > > > > > I do agree that we should try looking for Python 3 first, and only > > > afterwards for Python 2. > > > > > > Also, I think the test should start by looking for just "python", > > > before the versioned variants. > > > > > > E.g., on my system (executable-find "python3") returns nil, although I > > > have Python 3.x installed -- but it's installed under the name > > > "python". > > Thanks for the comment, and it's true that python2 will still exist > > for many years. > > And I had changed the test case to adapt python/python3/python2 automat= ically. > > Please help review the new patch. Thanks. >=20 > Thanks. >=20 > kobarity, any comments, or should I install this? I agree with the policy to support both Python 2/3. How about a patch like the one attached? --Multipart_Fri_May_10_01:00:11_2024-1 Content-Type: application/octet-stream; type=patch; name="0001-Support-Python-3-in-package-test-update-archives-asy.patch" Content-Disposition: attachment; filename="0001-Support-Python-3-in-package-test-update-archives-asy.patch" Content-Transfer-Encoding: 7bit >From 7d5fff9814517da14a45a45bd14e8152ae4bf6fc Mon Sep 17 00:00:00 2001 From: kobarity Date: Fri, 10 May 2024 00:39:10 +0900 Subject: [PATCH] Support Python 3 in package-test-update-archives-async * test/lisp/emacs-lisp/package-resources/package-test-server.py: Support Python 3. * test/lisp/emacs-lisp/package-tests.el (package-test-update-archives-async): Search for an executable named python, python3, or python2. (Bug#70722) Co-authored-by: Lin Sun --- .../package-resources/package-test-server.py | 24 ++++++++----------- test/lisp/emacs-lisp/package-tests.el | 9 +++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/test/lisp/emacs-lisp/package-resources/package-test-server.py b/test/lisp/emacs-lisp/package-resources/package-test-server.py index 128b4249ec3..16f3e391aa1 100644 --- a/test/lisp/emacs-lisp/package-resources/package-test-server.py +++ b/test/lisp/emacs-lisp/package-resources/package-test-server.py @@ -1,23 +1,19 @@ import sys -import BaseHTTPServer -from SimpleHTTPServer import SimpleHTTPRequestHandler +try: + from http.server import HTTPServer, SimpleHTTPRequestHandler +except ImportError: + from BaseHTTPServer import HTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler -HandlerClass = SimpleHTTPRequestHandler -ServerClass = BaseHTTPServer.HTTPServer -Protocol = "HTTP/1.0" - -if sys.argv[1:]: - port = int(sys.argv[1]) -else: - port = 0 -server_address = ('127.0.0.1', port) -HandlerClass.protocol_version = Protocol -httpd = ServerClass(server_address, HandlerClass) +HandlerClass = SimpleHTTPRequestHandler +HandlerClass.protocol_version = "HTTP/1.0" +server_address = ("127.0.0.1", int(sys.argv[1]) if sys.argv[1:] else 0) +httpd = HTTPServer(server_address, HandlerClass) ip, port = httpd.socket.getsockname()[0:2] -print ("Server started, http://%s:%s/" % (ip, port)) +print("Server started, http://%s:%s/" % (ip, port)) # Flush in case we're in full buffering mode (instead of line # buffering), this might happen if python is a cygwin program and we # run it from a native w32 program. diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index d95b94f2145..692d6550250 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el @@ -634,14 +634,15 @@ package-test-update-archives (ert-deftest package-test-update-archives-async () "Test updating package archives asynchronously." :tags '(:expensive-test) - (skip-unless (executable-find "python2")) (let* ((package-menu-async t) (default-directory package-test-data-dir) - (process (start-process + (python-interpreter (seq-some #'executable-find '("python" "python3" "python2"))) + process addr) + (skip-unless python-interpreter) + (setq process (start-process "package-server" "package-server-buffer" - (executable-find "python2") + python-interpreter "package-test-server.py")) - (addr nil)) (unwind-protect (progn (with-current-buffer "package-server-buffer" -- 2.34.1 --Multipart_Fri_May_10_01:00:11_2024-1--