From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MIw4OIAhZmKA+gAAbAwnHQ (envelope-from ) for ; Mon, 25 Apr 2022 06:20:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YIQ+N4AhZmJxtgAAG6o9tA (envelope-from ) for ; Mon, 25 Apr 2022 06:20:16 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8EE7D2FEEA for ; Mon, 25 Apr 2022 06:20:16 +0200 (CEST) Received: from localhost ([::1]:41966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niqCt-0007pI-GH for larch@yhetil.org; Mon, 25 Apr 2022 00:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nipvM-0007wI-6l for guix-patches@gnu.org; Mon, 25 Apr 2022 00:02:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nipvK-0001d1-Jg for guix-patches@gnu.org; Mon, 25 Apr 2022 00:02:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nipvK-0008Ac-Fy for guix-patches@gnu.org; Mon, 25 Apr 2022 00:02:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55104] [PATCH 049/232] gnu: python-mypy: Update to 0.942 and fix search path. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 25 Apr 2022 04:02:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55104 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55104@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 55104-submit@debbugs.gnu.org id=B55104.165085931131188 (code B ref 55104); Mon, 25 Apr 2022 04:02:06 +0000 Received: (at 55104) by debbugs.gnu.org; 25 Apr 2022 04:01:51 +0000 Received: from localhost ([127.0.0.1]:60826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nipuw-00086k-U9 for submit@debbugs.gnu.org; Mon, 25 Apr 2022 00:01:51 -0400 Received: from mail-qv1-f50.google.com ([209.85.219.50]:42772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niptf-0007oB-2W for 55104@debbugs.gnu.org; Mon, 25 Apr 2022 00:00:31 -0400 Received: by mail-qv1-f50.google.com with SMTP id iy15so1893531qvb.9 for <55104@debbugs.gnu.org>; Sun, 24 Apr 2022 21:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eTxs6q2HPhkFBOcuI6FKD7Ar7B4Ze0nWR/MEpJkyVps=; b=duv6ftC2Hn+3Y/rqD/0u9sZRNBUGzx3MDi2BjHulW/KjOuc7ozTm9A/lXZ3GlSQ1dD fIWvkagZr4OGtOD0gE1/YVb3GzYZTOirBVNnqxURGpKkKzW7bN1MyC7MZzqX/WcD1IY0 lzcSMTT09swJhVOkPySR6d45BaM/JQ61Kt/qB0yKGeHrtJGEFhklB5S5mYR+75L4o6vk v7sdBrVhLxs+c8ElWPxKLa7+JbB0VfYxq8MiMPMP5bToT7nsjaeJf2+wnb6n2LE0vK38 tNOeW1eHjTLEwCwMqZBO/LPYCtGewb7mT1Cl3jcsiJFfkNyjvsSsg5ZPzWKKiPMw7dyy LwBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eTxs6q2HPhkFBOcuI6FKD7Ar7B4Ze0nWR/MEpJkyVps=; b=xa2vcKSGLkroxwyCqCZAJyg2PK3/Yt/sKxHlXokKOoiZ7xTtKRONsgIwACV4gMF7UG LzxSr8d3kctqBMqqM0dDiDBPFtrXuZYdP1mlUuFiFSCUR6kkWatSqs4yo5/nYgcv+hCk wg3GyQDYnSdEhRxTJbvqpLOBSgJUOxxOebLRF2C2nqHQfLlip3JExnUAl3VPTvD168Vv OZuWtqXxWHEPxkgQFeC7T0/JVEgIZMebD8wIlB1thzULOhEtK0JYe8w77h0WPH+4TdHy tkwKjBKKKaqWsKxy+0FQMcVrVDcvBMxFdDkoTHkbjkKldjSZnL1KQ2i+HPI3EaUEp8h8 NLKw== X-Gm-Message-State: AOAM5301UaPG0qZV1vrvTbGKj9QozEBtdOHsyw21MHQCB7Y+BZTIbvkV aM+n2jgMyIQSRX9JvGK2wkFcQudT8StU/Q== X-Google-Smtp-Source: ABdhPJyQZDs+gs3qN82h6IB+IxdiASKbJ5ijLW/ibA5om+bJHKrz0xLvBhTC+PtkNjCaKOdvOrcAQg== X-Received: by 2002:a05:6214:1c8c:b0:440:da6b:a3dc with SMTP id ib12-20020a0562141c8c00b00440da6ba3dcmr10965018qvb.12.1650859217366; Sun, 24 Apr 2022 21:00:17 -0700 (PDT) Received: from localhost.localdomain (dsl-150-232.b2b2c.ca. [66.158.150.232]) by smtp.gmail.com with ESMTPSA id w82-20020a376255000000b0069ee3f0ae63sm4478142qkb.45.2022.04.24.21.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 21:00:17 -0700 (PDT) From: Maxim Cournoyer Date: Sun, 24 Apr 2022 23:56:15 -0400 Message-Id: <20220425035918.25683-49-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220425035918.25683-1-maxim.cournoyer@gmail.com> References: <20220425035918.25683-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650860416; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=eTxs6q2HPhkFBOcuI6FKD7Ar7B4Ze0nWR/MEpJkyVps=; b=nqOUoH9YNOqG1px4ePmvMZlECIP2Pf1fNByZ3n0oDbAcyRmUhXorGiWpHmSWBRCEs2SNzY poLlxQsWsJR49+RM0rqByB42sgyxn3APnGCSyGkN5/bNqEWJ7PGj035Nn/5WIYc5Ir2MA5 lHjXD59m+Z4qVihgCpYMFrVnZANcRAdynxzx4hPaQNc6N+zvVztremNPsxAN3H7Fi+CkAw b2rTpgldXa1PXKetYRUeRj4l8fIFbqyvF6QjrvRJ8V2oWETGltOn2wrRatJoABg8Gy+P+a nxGiI6DGcDjIM/SWQWvytj6z4YoxJFEWA4p99Xw9XHFJH+xtsVKEUH2SI36ARA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650860416; a=rsa-sha256; cv=none; b=q5RwSbP5Mw0aQ8AvZvWaBbt+VaMrFPqXLRH0+jM/GRA3hioGtsegcNkzS4HPvH+ySO10gB zpPnIOZMDYFDhccxx3QouqlR3i6vjtGYYj4vamWe2c53JM7sA/1Ld3IvK9Gh5zcZoBVQfN aPn4Bhrkb4ExD7Gj8vT/OT0CbIBi4eLRibBWWkrAxMF+ra4cakaFDDkqCqVQEy0ZrcoxdP tdqAvbFEjGGvjeK/k8bz7Fne1+x/D/23FDhUsioG00G9KH+gsjCeb9Pzo+ow0PLCEm/f96 pqL7zRCWvBY/Ch08u+E1M0h6BK2l0/lqFkIcTzUz5vPjb+K3M6LtKFeGL1m6+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=duv6ftC2; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 7.49 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=duv6ftC2; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 8EE7D2FEEA X-Spam-Score: 7.49 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3CqvjB0T5MYu * gnu/packages/patches/python-mypy-use-sys-path.patch: New patch. * gnu/local.mk: Register it. * gnu/packages/python-check.scm (python-mypy): Update to 0.942. [source]: Apply patch. --- gnu/local.mk | 1 + .../patches/python-mypy-use-sys-path.patch | 130 ++++++++++++++++++ gnu/packages/python-check.scm | 15 +- 3 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 gnu/packages/patches/python-mypy-use-sys-path.patch diff --git a/gnu/local.mk b/gnu/local.mk index 9bad87710c..702c430623 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1720,6 +1720,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-waitress-fix-tests.patch \ %D%/packages/patches/python-werkzeug-tests.patch \ %D%/packages/patches/python-mypy-12332.patch \ + %D%/packages/patches/python-mypy-use-sys-path.patch \ %D%/packages/patches/qemu-build-info-manual.patch \ %D%/packages/patches/qemu-glibc-2.27.patch \ %D%/packages/patches/qemu-glibc-2.30.patch \ diff --git a/gnu/packages/patches/python-mypy-use-sys-path.patch b/gnu/packages/patches/python-mypy-use-sys-path.patch new file mode 100644 index 0000000000..1b12526456 --- /dev/null +++ b/gnu/packages/patches/python-mypy-use-sys-path.patch @@ -0,0 +1,130 @@ +This patch fixes the annotation files search of mypy on non-FHS distributions. + +Submitted upstream: https://github.com/python/mypy/pull/12530 + +diff --git a/mypy/main.py b/mypy/main.py +index 3d9836587..f9b0cbd39 100644 +--- a/mypy/main.py ++++ b/mypy/main.py +@@ -1033,10 +1033,10 @@ def process_options(args: List[str], + # Set target. + if special_opts.modules + special_opts.packages: + options.build_type = BuildType.MODULE +- egg_dirs, site_packages = get_site_packages_dirs(options.python_executable) ++ site_packages = get_site_packages_dirs(options.python_executable) + search_paths = SearchPaths((os.getcwd(),), + tuple(mypy_path() + options.mypy_path), +- tuple(egg_dirs + site_packages), ++ tuple(site_packages), + ()) + targets = [] + # TODO: use the same cache that the BuildManager will +diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py +index 94d2dd34c..337a2d59b 100644 +--- a/mypy/modulefinder.py ++++ b/mypy/modulefinder.py +@@ -629,7 +629,7 @@ def get_prefixes(python_executable: Optional[str]) -> Tuple[str, str]: + + + @functools.lru_cache(maxsize=None) +-def get_site_packages_dirs(python_executable: Optional[str]) -> Tuple[List[str], List[str]]: ++def get_site_packages_dirs(python_executable: Optional[str]) -> List[str]: + """Find package directories for given python. + + This runs a subprocess call, which generates a list of the egg directories, and the site +@@ -648,51 +648,7 @@ def get_site_packages_dirs(python_executable: Optional[str]) -> Tuple[List[str], + site_packages = ast.literal_eval( + subprocess.check_output([python_executable, pyinfo.__file__, 'getsitepackages'], + stderr=subprocess.PIPE).decode()) +- return expand_site_packages(site_packages) +- +- +-def expand_site_packages(site_packages: List[str]) -> Tuple[List[str], List[str]]: +- """Expands .pth imports in site-packages directories""" +- egg_dirs: List[str] = [] +- for dir in site_packages: +- if not os.path.isdir(dir): +- continue +- pth_filenames = sorted(name for name in os.listdir(dir) if name.endswith(".pth")) +- for pth_filename in pth_filenames: +- egg_dirs.extend(_parse_pth_file(dir, pth_filename)) +- +- return egg_dirs, site_packages +- +- +-def _parse_pth_file(dir: str, pth_filename: str) -> Iterator[str]: +- """ +- Mimics a subset of .pth import hook from Lib/site.py +- See https://github.com/python/cpython/blob/3.5/Lib/site.py#L146-L185 +- """ +- +- pth_file = os.path.join(dir, pth_filename) +- try: +- f = open(pth_file, "r") +- except OSError: +- return +- with f: +- for line in f.readlines(): +- if line.startswith("#"): +- # Skip comment lines +- continue +- if line.startswith(("import ", "import\t")): +- # import statements in .pth files are not supported +- continue +- +- yield _make_abspath(line.rstrip(), dir) +- +- +-def _make_abspath(path: str, root: str) -> str: +- """Take a path and make it absolute relative to root if not already absolute.""" +- if os.path.isabs(path): +- return os.path.normpath(path) +- else: +- return os.path.join(root, os.path.normpath(path)) ++ return site_packages + + + def add_py2_mypypath_entries(mypypath: List[str]) -> List[str]: +@@ -781,7 +737,7 @@ def compute_search_paths(sources: List[BuildSource], + if options.python_version[0] == 2: + mypypath = add_py2_mypypath_entries(mypypath) + +- egg_dirs, site_packages = get_site_packages_dirs(options.python_executable) ++ site_packages = get_site_packages_dirs(options.python_executable) + base_prefix, prefix = get_prefixes(options.python_executable) + is_venv = base_prefix != prefix + for site_dir in site_packages: +@@ -801,7 +757,7 @@ def compute_search_paths(sources: List[BuildSource], + + return SearchPaths(python_path=tuple(reversed(python_path)), + mypy_path=tuple(mypypath), +- package_path=tuple(egg_dirs + site_packages), ++ package_path=tuple(site_packages), + typeshed_path=tuple(lib_path)) + + +diff --git a/mypy/pyinfo.py b/mypy/pyinfo.py +index ab2d3286b..9fb0501a1 100644 +--- a/mypy/pyinfo.py ++++ b/mypy/pyinfo.py +@@ -24,16 +24,11 @@ def getprefixes(): + + def getsitepackages(): + # type: () -> List[str] +- res = [] +- if hasattr(site, 'getsitepackages'): +- res.extend(site.getsitepackages()) + +- if hasattr(site, 'getusersitepackages') and site.ENABLE_USER_SITE: +- res.insert(0, site.getusersitepackages()) +- else: +- from distutils.sysconfig import get_python_lib +- res = [get_python_lib()] +- return res ++ # Simply return sys.path, which has already been expanded ++ # correctly via Python's site.py module, which takes care of .pth, ++ # sitecustomize.py files, etc. ++ return sys.path + + + if __name__ == '__main__': diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm index 2d35eb720e..03895a44c7 100644 --- a/gnu/packages/python-check.scm +++ b/gnu/packages/python-check.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2019, 2021, 2022 Ricardo Wurmus ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019, 2020, 2021 Efraim Flashner -;;; Copyright © 2019, 2020, 2021 Maxim Cournoyer +;;; Copyright © 2019, 2020, 2021, 2022 Maxim Cournoyer ;;; Copyright © 2019, 2021 Hartmut Goebel ;;; Copyright © 2020 Julien Lepiller ;;; Copyright © 2020, 2022 Marius Bakke @@ -1672,7 +1672,7 @@ (define-public python-mypy-extensions (define-public python-mypy (package (name "python-mypy") - (version "0.931") + (version "0.942") (source (origin ;; Because of https://github.com/python/mypy/issues/9584, the @@ -1689,9 +1689,10 @@ (define-public python-mypy (file-name (git-file-name name version)) (sha256 (base32 - "1v83flrdxh8grcp40qw04q4hzjflih9xwib64078vsxv2w36f817")) + "0hxnrqhvskiclwfj2s4gyfclzjas1dvpfxhyng8v7mq38rqps1j5")) (patches - (search-patches "python-mypy-12332.patch")))) + (search-patches "python-mypy-12332.patch" + "python-mypy-use-sys-path.patch")))) (build-system python-build-system) (arguments `(#:phases @@ -1713,10 +1714,10 @@ (define-public python-mypy (home-page "http://www.mypy-lang.org/") (synopsis "Static type checker for Python") (description "Mypy is an optional static type checker for Python that aims -to combine the benefits of dynamic (or 'duck') typing and static typing. Mypy combines +to combine the benefits of dynamic typing and static typing. Mypy combines the expressive power and convenience of Python with a powerful type system and -compile-time type checking. Mypy type checks standard Python programs; run them using -any Python VM with basically no runtime overhead.") +compile-time type checking. Mypy type checks standard Python programs; run +them using any Python VM with basically no runtime overhead.") ;; Most of the code is under MIT license; Some files are under Python Software ;; Foundation License version 2: stdlib-samples/*, mypyc/lib-rt/pythonsupport.h and ;; mypyc/lib-rt/getargs.c -- 2.34.0