From patchwork Mon Aug 2 08:56:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 31720 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 62AEB27BC6B; Mon, 2 Aug 2021 09:57:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B194C27BC78 for ; Mon, 2 Aug 2021 09:57:10 +0100 (BST) Received: from localhost ([::1]:49986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mATkz-0004N7-M9 for patchwork@mira.cbaines.net; Mon, 02 Aug 2021 04:57:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mATks-0004Kl-UB for guix-patches@gnu.org; Mon, 02 Aug 2021 04:57:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mATks-0006Ys-MD for guix-patches@gnu.org; Mon, 02 Aug 2021 04:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mATks-0000NK-LI for guix-patches@gnu.org; Mon, 02 Aug 2021 04:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49818] [PATCH] gnu: Add python-pyan3. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 Aug 2021 08:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49818 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49818@debbugs.gnu.org Cc: Arun Isaac X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16278946141426 (code B ref -1); Mon, 02 Aug 2021 08:57:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Aug 2021 08:56:54 +0000 Received: from localhost ([127.0.0.1]:37688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mATke-0000Mq-HD for submit@debbugs.gnu.org; Mon, 02 Aug 2021 04:56:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:36860) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mATkd-0000Mj-50 for submit@debbugs.gnu.org; Mon, 02 Aug 2021 04:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mATkc-0003ub-Qw for guix-patches@gnu.org; Mon, 02 Aug 2021 04:56:46 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:47884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mATkY-0006DT-2Q for guix-patches@gnu.org; Mon, 02 Aug 2021 04:56:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SF3j7kdBVbMsTI5BpzKOWBkF30yYLyrVssAT7m4LwZw=; b=bTR/Rps0t/JDXDHO0dch/tYLAB W/UmXSu7oHyyoU1skkBpY/IjHUDj09HteN+bQnk+LBMRYHz+FCjmPwAo640sUufJU89Fq8Wx+PszS RzhIcDEJjg8tr4oOej0pvmBauXfJDa0Jn6DyKCWvlYVZf4GYS6Ug+2wCDmQt+y4m37PjLFSC/kuLV 0qKNBd8V9tYtMxJ5XknIDETov+4fT1bSGQmt8gg40QMIhsJtymEOPrqhmsadcBPEskUAXRuYhbjDx EGWsqsOAVAEvH/wydwmgOS+7k7ndbLCGJcrBCqxvfaqlt/av/jzZOiIjMy76fW4nEXsruGMa02vLN sZWvG4xw==; Received: from [192.168.2.1] (helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mATkQ-000551-3D; Mon, 02 Aug 2021 14:26:34 +0530 From: Arun Isaac Date: Mon, 2 Aug 2021 14:26:15 +0530 Message-Id: <20210802085615.2020-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Received-SPF: pass client-ip=139.59.75.54; envelope-from=arunisaac@systemreboot.net; helo=mugam.systemreboot.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/python-xyz.scm (python-pyan3): New variable. * gnu/packages/patches/python-pyan3-fix-absolute-path-bug.patch, gnu/packages/patches/python-pyan3-fix-positional-arguments.patch: New files. * gnu/local.mk: Register them. --- gnu/local.mk | 2 + .../python-pyan3-fix-absolute-path-bug.patch | 160 ++++++++++++++++++ ...ython-pyan3-fix-positional-arguments.patch | 22 +++ gnu/packages/python-xyz.scm | 42 +++++ 4 files changed, 226 insertions(+) create mode 100644 gnu/packages/patches/python-pyan3-fix-absolute-path-bug.patch create mode 100644 gnu/packages/patches/python-pyan3-fix-positional-arguments.patch diff --git a/gnu/local.mk b/gnu/local.mk index c530507b1a..f8e14e05b9 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1641,6 +1641,8 @@ dist_patch_DATA = \ %D%/packages/patches/python-paste-remove-timing-test.patch \ %D%/packages/patches/python-pycrypto-CVE-2013-7459.patch \ %D%/packages/patches/python-pycrypto-time-clock.patch \ + %D%/packages/patches/python-pyan3-fix-absolute-path-bug.patch \ + %D%/packages/patches/python-pyan3-fix-positional-arguments.patch \ %D%/packages/patches/python-pydot-regression-test.patch \ %D%/packages/patches/python2-pygobject-2-deprecation.patch \ %D%/packages/patches/python-pygpgme-fix-pinentry-tests.patch \ diff --git a/gnu/packages/patches/python-pyan3-fix-absolute-path-bug.patch b/gnu/packages/patches/python-pyan3-fix-absolute-path-bug.patch new file mode 100644 index 0000000000..0b6a083fa3 --- /dev/null +++ b/gnu/packages/patches/python-pyan3-fix-absolute-path-bug.patch @@ -0,0 +1,160 @@ +From ac1bd55d07fd1bad2f4a92dc0809607c407d9140 Mon Sep 17 00:00:00 2001 +From: "Maciej A. Czyzewski" +Date: Wed, 9 Jun 2021 15:29:18 +0200 +Subject: [PATCH] feature: new params for graphviz + solves #70 + +- solve abs path bug #70 +- new params for graphviz (ranksep; layout) +- tested layout `dot`; `fdp` (square graph) +- updated `.gitignore` (files gen. after `visualize_pyan_architecture.sh`) +--- + .gitignore | 5 ++++ + README.md | 6 ++-- + pyan/main.py | 55 +++++++++++++++++++++++++++++++--- + visualize_pyan_architecture.sh | 5 ++++ + 4 files changed, 64 insertions(+), 7 deletions(-) + +diff --git a/.gitignore b/.gitignore +index 990fdc0c..93313aaf 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -162,3 +162,8 @@ htmlcov + .idea/ + .history/ + .vscode/ ++ ++# our vis. of architecture ++architecture.dot ++architecture.html ++architecture.svg +diff --git a/README.md b/README.md +index d1f19dcf..9e6919a3 100644 +--- a/README.md ++++ b/README.md +@@ -48,7 +48,7 @@ See `pyan3 --help`. + + Example: + +-`pyan *.py --uses --no-defines --colored --grouped --annotated --dot >myuses.dot` ++`pyan3 *.py --uses --no-defines --colored --grouped --annotated --dot >myuses.dot` + + Then render using your favorite GraphViz filter, mainly `dot` or `fdp`: + +@@ -56,11 +56,11 @@ Then render using your favorite GraphViz filter, mainly `dot` or `fdp`: + + Or use directly + +-`pyan *.py --uses --no-defines --colored --grouped --annotated --svg >myuses.svg` ++`pyan3 *.py --uses --no-defines --colored --grouped --annotated --svg >myuses.svg` + + You can also export as an interactive HTML + +-`pyan *.py --uses --no-defines --colored --grouped --annotated --html > myuses.html` ++`pyan3 *.py --uses --no-defines --colored --grouped --annotated --html > myuses.html` + + Alternatively, you can call `pyan` from a script + +diff --git a/pyan/main.py b/pyan/main.py +index 5d079714..b1a16f63 100644 +--- a/pyan/main.py ++++ b/pyan/main.py +@@ -141,6 +141,31 @@ def main(cli_args=None): + ), + ) + ++ parser.add_argument( ++ "--dot-ranksep", ++ default="0.5", ++ dest="ranksep", ++ help=( ++ "specifies the dot graph 'ranksep' property for " ++ "controlling desired rank separation, in inches. " ++ "Allowed values: [0.02 .. 1000.0]. " ++ "[dot only]" ++ ), ++ ) ++ ++ parser.add_argument( ++ "--graphviz-layout", ++ default="dot", ++ dest="layout", ++ help=( ++ "specifies the graphviz 'layout' property for " ++ "the name of the layout algorithm to use. " ++ "Allowed values: ['dot', 'neato', 'fdp', 'sfdp', 'twopi', 'circo']. " ++ "Recommended values: ['dot', 'fdp']. " ++ "[graphviz only]" ++ ), ++ ) ++ + parser.add_argument( + "-a", + "--annotated", +@@ -159,7 +184,12 @@ def main(cli_args=None): + + known_args, unknown_args = parser.parse_known_args(cli_args) + +- filenames = [fn2 for fn in unknown_args for fn2 in glob(fn, recursive=True)] ++ ++ filenames = [] ++ for fn in unknown_args: ++ for fn2 in glob(fn, recursive=True): ++ abs_fn2 = os.path.abspath(fn2) ++ filenames.append(abs_fn2) + + # determine root + if known_args.root is not None: +@@ -203,6 +233,11 @@ def main(cli_args=None): + handler = logging.FileHandler(known_args.logname) + logger.addHandler(handler) + ++ logger.debug(f"[files] {unknown_args}") ++ ++ if root: ++ root = os.path.abspath(root) ++ + v = CallGraphVisitor(filenames, logger=logger, root=root) + + if known_args.function or known_args.namespace: +@@ -222,13 +257,25 @@ def main(cli_args=None): + writer = None + + if known_args.dot: +- writer = DotWriter(graph, options=["rankdir=" + known_args.rankdir], output=known_args.filename, logger=logger) ++ writer = DotWriter(graph, options=[ ++ "rankdir=" + known_args.rankdir, ++ "ranksep=" + known_args.ranksep, ++ "layout=" + known_args.layout, ++ ], output=known_args.filename, logger=logger) + + if known_args.html: +- writer = HTMLWriter(graph, options=["rankdir=" + known_args.rankdir], output=known_args.filename, logger=logger) ++ writer = HTMLWriter(graph, options=[ ++ "rankdir=" + known_args.rankdir, ++ "ranksep=" + known_args.ranksep, ++ "layout=" + known_args.layout, ++ ], output=known_args.filename, logger=logger) + + if known_args.svg: +- writer = SVGWriter(graph, options=["rankdir=" + known_args.rankdir], output=known_args.filename, logger=logger) ++ writer = SVGWriter(graph, options=[ ++ "rankdir=" + known_args.rankdir, ++ "ranksep=" + known_args.ranksep, ++ "layout=" + known_args.layout, ++ ], output=known_args.filename, logger=logger) + + if known_args.tgf: + writer = TgfWriter(graph, output=known_args.filename, logger=logger) +diff --git a/visualize_pyan_architecture.sh b/visualize_pyan_architecture.sh +index 22c63342..81b6ca24 100755 +--- a/visualize_pyan_architecture.sh ++++ b/visualize_pyan_architecture.sh +@@ -2,3 +2,8 @@ + echo -ne "Pyan architecture: generating architecture.{dot,svg}\n" + python3 -m pyan pyan/*.py --no-defines --uses --colored --annotate --dot -V >architecture.dot 2>architecture.log + dot -Tsvg architecture.dot >architecture.svg ++echo -ne "Pyan architecture: generating architecture.{html,graphviz=fdp}\n" ++python3 -m pyan pyan/*.py --no-defines --uses \ ++ --grouped --nested-groups \ ++ --graphviz-layout fdp \ ++ --colored --html > architecture.html diff --git a/gnu/packages/patches/python-pyan3-fix-positional-arguments.patch b/gnu/packages/patches/python-pyan3-fix-positional-arguments.patch new file mode 100644 index 0000000000..81923d7a41 --- /dev/null +++ b/gnu/packages/patches/python-pyan3-fix-positional-arguments.patch @@ -0,0 +1,22 @@ +From 37404bb039bd9c5509b4aec8f61e360dfba50715 Mon Sep 17 00:00:00 2001 +From: Wenxin Ling +Date: Mon, 1 Mar 2021 15:21:16 +0100 +Subject: [PATCH] Fix positional arguments issue for CallGraphVisitor + +--- + pyan/main.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pyan/main.py b/pyan/main.py +index 18821a14..5d079714 100644 +--- a/pyan/main.py ++++ b/pyan/main.py +@@ -203,7 +203,7 @@ def main(cli_args=None): + handler = logging.FileHandler(known_args.logname) + logger.addHandler(handler) + +- v = CallGraphVisitor(filenames, logger, root=root) ++ v = CallGraphVisitor(filenames, logger=logger, root=root) + + if known_args.function or known_args.namespace: + diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 61db9febb8..5b4b523d7b 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -26191,3 +26191,45 @@ enabling you to write CommonMark inside of Docutils & Sphinx projects.") Qhull} for the computation of the convex hull, Delaunay triangulation, and Voronoi diagram.") (license license:expat))) + +(define-public python-pyan3 + (package + (name "python-pyan3") + (version "1.2.0") + (source + (origin + ;; Source tarball on PyPI lacks tests. + (method git-fetch) + (uri (git-reference + (url "https://github.com/Technologicat/pyan") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1367x25rcy2y8f0x9c2dbxl2qgdln3arr7ddyzybz2c28g6jrv5z")) + (patches (search-patches "python-pyan3-fix-positional-arguments.patch" + "python-pyan3-fix-absolute-path-bug.patch")))) + (build-system python-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (replace 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + ;; Extend PYTHONPATH so the built package will be found. + (setenv "PYTHONPATH" + (string-append (getcwd) ":" (getenv "PYTHONPATH"))) + (invoke "pytest"))))))) + (native-inputs + `(("python-pytest" ,python-pytest) + ("python-pytest-cov" ,python-pytest-cov) + ("python-wheel" ,python-wheel))) + (propagated-inputs + `(("python-jinja2" ,python-jinja2))) + (home-page "https://github.com/Technologicat/pyan") + (synopsis "Offline call graph generator for Python 3") + (description "Pyan takes one or more Python source files, performs +a (rather superficial) static analysis, and constructs a directed graph of the +objects in the combined source, and how they define or use each other. The +graph can be output for rendering by GraphViz or yEd.") + (license license:gpl2)))