From patchwork Sat Sep 7 16:56:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 67734 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 5E1D427BBE2; Sat, 7 Sep 2024 17:57:47 +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=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,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 8253A27BBEA for ; Sat, 7 Sep 2024 17:57:46 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smykG-0000tm-5W; Sat, 07 Sep 2024 12:57:08 -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 1smykD-0000sJ-MQ for guix-patches@gnu.org; Sat, 07 Sep 2024 12:57:06 -0400 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 1smykD-0001c9-D8 for guix-patches@gnu.org; Sat, 07 Sep 2024 12:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=a9IJwNMVg+UimD6j2vBkMVbhVqHLEOGWc4FfCSE2VJI=; b=tdhfhAHWQmBaox2bAIvAt4i31xV4P5ZfOcy2nzM01iZVZhEnNujLOwCMUViPDKblSnnY1Q/J6SrPzVlzjp5/aiRW8M8ya2/f9b55o5reJJVguDBgilIXmu+Q+NOrmqEWRZMNATZQpyQ9cS+a+txMtsbFak+AahmWAme88FF3cRxCfXsiWoYGRr9RzIoDsTuDZWUEP8HSRz8X76YxSR8PWAi3ymjzYdEYjIvkGyExzg5Ir07QE8k23gJdXkcGBunpt9eE/i3yxY9M7U89qDel0tSpv4ii5h/ghHo8sA36/Pqq4j7Q7YjVu5swaD2ppj6yyj+R0CCcbDjc1CfLqiSGnQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1smykE-0007wh-CC for guix-patches@gnu.org; Sat, 07 Sep 2024 12:57:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73106] [PATCH 10/10] gnu: Add python-tokenizers. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 07 Sep 2024 16:57:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73106 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73106@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 73106-submit@debbugs.gnu.org id=B73106.172572820630446 (code B ref 73106); Sat, 07 Sep 2024 16:57:06 +0000 Received: (at 73106) by debbugs.gnu.org; 7 Sep 2024 16:56:46 +0000 Received: from localhost ([127.0.0.1]:57455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smyjt-0007uu-GF for submit@debbugs.gnu.org; Sat, 07 Sep 2024 12:56:46 -0400 Received: from 7.mo583.mail-out.ovh.net ([178.32.124.100]:58157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smyjp-0007u3-7S for 73106@debbugs.gnu.org; Sat, 07 Sep 2024 12:56:42 -0400 Received: from director7.ghost.mail-out.ovh.net (unknown [10.109.140.39]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 4X1K4k6C6Sz1TJd for <73106@debbugs.gnu.org>; Sat, 7 Sep 2024 16:56:38 +0000 (UTC) Received: from ghost-submission-55b549bf7b-ttspb (unknown [10.110.168.221]) by director7.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 992EC1FD63; Sat, 7 Sep 2024 16:56:38 +0000 (UTC) Received: from ngraves.fr ([37.59.142.105]) by ghost-submission-55b549bf7b-ttspb with ESMTPSA id l+/lHcaF3GbMtgEAqJuKVw (envelope-from ); Sat, 07 Sep 2024 16:56:38 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-105G00690f40d5b-7c1c-4d9e-9646-f5bd876ddaf2, 9FD0014F98746B3795650381BBEC0664E0950E21) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.146.208 Date: Sat, 7 Sep 2024 18:56:16 +0200 Message-ID: <20240907165626.22651-10-ngraves@ngraves.fr> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240907165626.22651-1-ngraves@ngraves.fr> References: <20240907165626.22651-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 9639392055524713186 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedguddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeekgeejtdeigeeiteekjeeujeegtdekkedvgeehveefiedvieeuvdfhvddutdfgteenucffohhmrghinhephhhughhgihhnghhfrggtvgdrtghonecukfhppeduvdejrddtrddtrddupdekuddrieejrddugeeirddvtdekpdefjedrheelrddugedvrddutdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopeejfedutdeiseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkeefpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=a9IJwNMVg+UimD6j2vBkMVbhVqHLEOGWc4FfCSE2VJI=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1725728198; v=1; b=Ee/Ha59P81bFONZvRIPVu6pCN3BoDX/407gdnSifdym73CGq/c62N56WjXadxfXrhNlBgJyk DxtKpVtvkI3bsdo26nl7TmDcqiptFm3Pfn9jyX0G+BlDvoiUWjrchNkNlizEk1cXQy8wBzMVWtY jOfXOjrbD6oJJq6McPsK0BILuSMid1HExJTTAsdhE3kB/OVAKvF+9BaaVHBhZeOUtxOtH+Pcmou HgYP0PF4i20fFWmlVRDUynOdi5Us7UU+GSFWS2+9k/ToKMvtzUslR7yYkvLEmmH5Zy9jeLpHv3I MCg7jrXPopqiU91nN4+SRpP+6tZlZOuVocqWOcUwrwXvQ== 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/machine-learning.scm (python-tokenizers): New variable. Change-Id: I5db95172255dc4635c2a417f3b7252454eea27d7 --- gnu/packages/machine-learning.scm | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 3b601f6c91..412499d424 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -5735,6 +5735,117 @@ (define-public rust-tokenizers tokenizers, with a focus on performances and versatility.") (license license:asl2.0))) +(define-public python-tokenizers + (package + (name "python-tokenizers") + (version "0.19.1") + (source + (origin + (method url-fetch) + (uri (pypi-uri "tokenizers" version)) + (sha256 + (base32 "1qw8mjp0q9w7j1raq1rvcbfw38000kbqpwscf9mvxzfh1rlfcngf")) + (modules '((guix build utils) + (ice-9 ftw))) + (snippet + #~(begin ;; Only keeping bindings. + (for-each (lambda (file) + (unless (member file '("." ".." "bindings" "PKG-INFO")) + (delete-file-recursively file))) + (scandir ".")) + (for-each (lambda (file) + (unless (member file '("." "..")) + (rename-file (string-append "bindings/python/" file) file))) + (scandir "bindings/python")) + (delete-file-recursively ".cargo"))))) + (build-system cargo-build-system) + (arguments + (list + #:cargo-test-flags ''("--no-default-features") + #:imported-modules `(,@%cargo-build-system-modules + ,@%pyproject-build-system-modules) + #:modules '((guix build cargo-build-system) + ((guix build pyproject-build-system) #:prefix py:) + (guix build utils) + (ice-9 regex) + (ice-9 textual-ports)) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack-rust-crates 'inject-tokenizers + (lambda _ + (substitute* "Cargo.toml" + (("\\[dependencies\\]") + (format #f " +[dev-dependencies] +tempfile = ~s +pyo3 = { version = ~s, features = [\"auto-initialize\"] } + +[dependencies] +tokenizers = ~s" + #$(package-version rust-tempfile-3) + #$(package-version rust-pyo3-0.21) + #$(package-version rust-tokenizers)))) + (let ((file-path "Cargo.toml")) + (call-with-input-file file-path + (lambda (port) + (let* ((content (get-string-all port)) + (top-match (string-match + "\\[dependencies.tokenizers" content))) + (call-with-output-file file-path + (lambda (out) + (format out "~a" (match:prefix top-match)))))))))) + (add-after 'patch-cargo-checksums 'loosen-requirements + (lambda _ + (substitute* "Cargo.toml" + (("version = \"6.4\"") + (format #f "version = ~s" + #$(package-version rust-onig-6)))))) + (add-after 'check 'python-check + (lambda _ + (copy-file "target/release/libtokenizers.so" + "py_src/tokenizers/tokenizers.so") + (invoke "python3" + "-c" (format #f + "import sys; sys.path.append(\"~a/py_src\")" + (getcwd)) + "-m" "pytest" + "-s" "-v" "./tests/"))) + (add-after 'install 'install-python + (lambda _ + (let* ((pversion #$(version-major+minor (package-version python))) + (lib (string-append #$output "/lib/python" pversion + "/site-packages/")) + (info (string-append lib "tokenizers-" + #$(package-version this-package) + ".dist-info"))) + (mkdir-p info) + (copy-file "PKG-INFO" (string-append info "/METADATA")) + (copy-recursively + "py_src/tokenizers" + (string-append lib "tokenizers")))))) + #:cargo-inputs + `(("rust-rayon" ,rust-rayon-1) + ("rust-serde" ,rust-serde-1) + ("rust-serde-json" ,rust-serde-json-1) + ("rust-libc" ,rust-libc-0.2) + ("rust-env-logger" ,rust-env-logger-0.11) + ("rust-pyo3" ,rust-pyo3-0.21) + ("rust-numpy" ,rust-numpy-0.21) + ("rust-ndarray" ,rust-ndarray-0.15) + ("rust-onig" ,rust-onig-6) + ("rust-itertools" ,rust-itertools-0.12) + ("rust-tokenizers" ,rust-tokenizers)) + #:cargo-development-inputs + `(("rust-tempfile" ,rust-tempfile-3)))) + (native-inputs + (list python-minimal python-pytest)) + (home-page "https://huggingface.co/docs/tokenizers") + (synopsis "Implementation of various popular tokenizers") + (description + "This package provides bindings to a Rust implementation of the most used +tokenizers, @code{rust-tokenizers}.") + (license license:asl2.0))) + (define-public python-hmmlearn (package (name "python-hmmlearn")