From patchwork Tue Jun 6 08:35:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 50728 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 21DF927BBE9; Tue, 6 Jun 2023 09:36:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3A24D27BBE2 for ; Tue, 6 Jun 2023 09:36:11 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6SAe-0003zQ-5M; Tue, 06 Jun 2023 04:36:04 -0400 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 1q6SAc-0003zF-I5 for guix-patches@gnu.org; Tue, 06 Jun 2023 04:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6SAc-0006xm-1c for guix-patches@gnu.org; Tue, 06 Jun 2023 04:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q6SAb-0005TY-TK for guix-patches@gnu.org; Tue, 06 Jun 2023 04:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63906] [PATCH v2] gnu: Add python-tree-sitter. References: In-Reply-To: Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 06 Jun 2023 08:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63906 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63906@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 63906-submit@debbugs.gnu.org id=B63906.168604052220995 (code B ref 63906); Tue, 06 Jun 2023 08:36:01 +0000 Received: (at 63906) by debbugs.gnu.org; 6 Jun 2023 08:35:22 +0000 Received: from localhost ([127.0.0.1]:50915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6S9y-0005SY-4h for submit@debbugs.gnu.org; Tue, 06 Jun 2023 04:35:22 -0400 Received: from 2.mo583.mail-out.ovh.net ([178.33.109.111]:32893) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6S9u-0005SE-P8 for 63906@debbugs.gnu.org; Tue, 06 Jun 2023 04:35:20 -0400 Received: from director9.ghost.mail-out.ovh.net (unknown [10.108.20.46]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id A885825AAF for <63906@debbugs.gnu.org>; Tue, 6 Jun 2023 08:35:14 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-tgcsr (unknown [10.108.16.203]) by director9.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 23A7E1FEE1; Tue, 6 Jun 2023 08:35:10 +0000 (UTC) Received: from ngraves.fr ([37.59.142.108]) by ghost-submission-6684bf9d7b-tgcsr with ESMTPSA id roorO77vfmTIAAAA5+jKlw (envelope-from ); Tue, 06 Jun 2023 08:35:10 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S00291cbd5cf-7769-44d4-928a-c42a708b60b1, 284FFE76C51B42248200B3458697F266C438202D) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.140.142 Date: Tue, 6 Jun 2023 10:35:08 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Ovh-Tracer-Id: 17276371120788398818 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgedtuddgtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeelueehgfevfeevhffftdetgedugeevveehteeileeuueejhfegffetteffhffhvdenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugedtrddugedvpdefjedrheelrddugedvrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeeifeeltdeiseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkeefpdhmohguvgepshhmthhpohhuth 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/tree-sitter.scm (python-tree-sitter): New variable. --- gnu/packages/tree-sitter.scm | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 853507be2d..20bd4466cc 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2022 muradm ;;; Copyright © 2022 Aleksandr Vityazev ;;; Copyright © 2023 Andrew Tropin +;;; Copyright © 2023 Nicolas Graves ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,7 @@ (define-module (gnu packages tree-sitter) #:use-module ((guix licenses) #:prefix license:) + #:use-module (gnu packages) #:use-module (gnu packages crates-graphics) #:use-module (gnu packages crates-io) #:use-module (gnu packages graphviz) @@ -29,13 +31,69 @@ (define-module (gnu packages tree-sitter) #:use-module (gnu packages node) #:use-module (guix build-system cargo) #:use-module (guix build-system gnu) + #:use-module (guix build-system pyproject) #:use-module (guix build-system tree-sitter) #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix packages) #:use-module (guix utils)) +(define-public python-tree-sitter + (package + (name "python-tree-sitter") + (version "0.20.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/tree-sitter/py-tree-sitter") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1rc8zqiry4n52xlf7pwx4s56ka9vwjzwgn7blwbkiscqdwvsai92")))) + (build-system pyproject-build-system) + (arguments + (list + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'set-tree-sitter-lib-path + (lambda _ + (let ((tree-sitter #$(this-package-input "tree-sitter"))) + (substitute* "setup.py" + (((string-append + "( *)\\[\"tree_sitter\\/core\\/lib\\/src\\/lib\\.c\", " + "\"tree_sitter\\/binding\\.c\"\\],") all tabs) + (string-append + tabs "[\"tree_sitter/binding.c\"],\n" + tabs "library_dirs=[\"" tree-sitter "/lib\"],\n" + tabs "libraries=[\"tree-sitter\"],")) + (("include_dirs=.*") + (string-append + "include_dirs=[\"" tree-sitter "/include\"],\n")))))) + (add-before 'check 'set-test-lib-paths + (lambda _ + (let ((py #$(this-package-native-input "tree-sitter-python")) + (js #$(this-package-native-input "tree-sitter-javascript"))) + (substitute* "tests/test_tree_sitter.py" + (("Language\\.build_library") + "_ =") + (("LIB_PATH(, \"python\")" all name) + (string-append + "\"" py "/lib/tree-sitter/libtree-sitter-python.so\"" name)) + (("LIB_PATH(, \"javascript\")" all name) + (string-append + "\"" js "/lib/tree-sitter/libtree-sitter-javascript.so\"" + name))))))))) + (inputs (list tree-sitter)) + (native-inputs + (list tree-sitter-python tree-sitter-javascript)) + (home-page "https://github.com/tree-sitter/py-tree-sitter") + (synopsis "Python bindings to the Tree-sitter parsing library") + (description "This package provides Python bindings to the +Tree-sitter parsing library.") + (license license:expat))) + (define-public tree-sitter (package (name "tree-sitter")