From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id MLENEYBp+2WgAAAA62LTzQ:P1 (envelope-from ) for ; Wed, 20 Mar 2024 23:56:00 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id MLENEYBp+2WgAAAA62LTzQ (envelope-from ) for ; Wed, 20 Mar 2024 23:56:00 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=b8appGVh; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1710975360; 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=pHbe726Df1pGF9aBySpYKAXIgFOPDs1Yd21jH2UkSr8=; b=ZkvkKEUi15WKH3fADQ+MYkUkEffxthHSwOl7ml5tJUvSXxZ9/XNr+2kZLrj5jIcAOY7Ybb XaQ3FLXkvoe10z0waxIyaOBeDnukVozJB1LlFc5/C3C8N3Zff0HiDDhU6g+pUYlffz3r+/ NVVSuJlPvT9s85hW23yFH9/eKCWDHCYnTGxguIjXPPjzDqYS9cH32A1bCN6piiLBhkxoaS IM6cGF0TPqrVBR2Nz+G8sMBfDItcN4dtzlbNbjux/8Yw6TkXOjw21q3Ni437dxzTfGjRwu KfLNsdJXf+WvOWRkaPc24U3LSR/G5PihDl8TOSFfkGpEo9jMOFNnnmKxrJdxgA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=b8appGVh; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1710975360; a=rsa-sha256; cv=none; b=XU5/CG4FgaogUUqe97VLpW7p12frLQ9Oww+QlbRv8KYaZB1gq8DdAdzjr6z6T0DKZbeoED sKpxkACSISmMvOlEDcNS2EzwmoM5Nb3n2txMmXZ0e6P9T2mJz57tubMBr7R/dmer3HSNFw SmMlVpnibjH6HLgXmQ0TIp/LngfVoKKTRnjk3TvaldoGQ+rKbgBPn0/5S+pEWBobVnZn41 ZOV9GZE98lJ/L7RMizi6nA6XQ8El4kGwIs6l1+px4DJM4eVdgOFWTdgQVAVpzmc3dHaQo7 sY51Rk+77UavR5ZoWg76vLr4DS1s3NirvqyYzQLQ2QeNe/I6EfQTIjl41FZEIQ== 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 0DD4B63F47 for ; Wed, 20 Mar 2024 23:56:00 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rn4bh-0005tf-He; Wed, 20 Mar 2024 18:40:25 -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 1rn4bg-0005t9-3e for guix-patches@gnu.org; Wed, 20 Mar 2024 18:40:24 -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 1rn4bf-0007b6-Oe for guix-patches@gnu.org; Wed, 20 Mar 2024 18:40:23 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rn4cJ-0006CG-9n for guix-patches@gnu.org; Wed, 20 Mar 2024 18:41:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69591] [PATCH v3 03/32] gnu: Add python-optree. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2024 22:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69591@debbugs.gnu.org Cc: David Elsing Received: via spool by 69591-submit@debbugs.gnu.org id=B69591.171097442323506 (code B ref 69591); Wed, 20 Mar 2024 22:41:03 +0000 Received: (at 69591) by debbugs.gnu.org; 20 Mar 2024 22:40:23 +0000 Received: from localhost ([127.0.0.1]:36791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rn4be-00066y-Le for submit@debbugs.gnu.org; Wed, 20 Mar 2024 18:40:23 -0400 Received: from mout02.posteo.de ([185.67.36.66]:45023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rn4bG-00062Z-KY for 69591@debbugs.gnu.org; Wed, 20 Mar 2024 18:39:59 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6E47E240101 for <69591@debbugs.gnu.org>; Wed, 20 Mar 2024 23:39:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1710974353; bh=JmN0vzDIbEKvNGzBL9EH0qHS0Qc2yiXMS0Twf+gbDaM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=b8appGVhO+dfet34dnQCbNBpKgKnvxP/FlUfkhvluC5+vxJUHZDlBqBdve8q1OJxl 1Zk6gSoDR1Vo2QhKZMFOWvyru2gXiojadpIFttSKXSpsG83l8a0gnD4g+A8VfvHIAB DVnfImM5k9M6TirKvlf4+amu2gahKCJ9A8xUBNT7MBeGKdzhCuEpIIuIo1dTTYGHvA D5xZfpCeTKTgCWCeDWY/ZZzonExag/k8VowaRt63aCJgkDFDMyRW/1wUKoz/1oXDFP DyTZ0ev4L1ajiHQqjMEtYi2x6TC3O2koP95mkdgdcjwwrAEG6hRD3BoQQE2CRB/tHq J7ozHO6yUYzuQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V0Nmw61z6z6tvq; Wed, 20 Mar 2024 23:39:12 +0100 (CET) From: David Elsing Date: Wed, 20 Mar 2024 22:38:28 +0000 Message-ID: <20240320223906.13214-3-david.elsing@posteo.net> In-Reply-To: <20240320223737.12883-1-david.elsing@posteo.net> References: <20240320223737.12883-1-david.elsing@posteo.net> 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.42 X-Spam-Score: -4.42 X-Migadu-Queue-Id: 0DD4B63F47 X-Migadu-Scanner: mx12.migadu.com X-TUID: Iha0pRUTpL1n * gnu/packages/python-xyz.scm (python-optree): New variable. --- .../patches/python-optree-fix-32-bit.patch | 122 ++++++++++++++++++ gnu/packages/python-xyz.scm | 30 +++++ 2 files changed, 152 insertions(+) create mode 100644 gnu/packages/patches/python-optree-fix-32-bit.patch diff --git a/gnu/packages/patches/python-optree-fix-32-bit.patch b/gnu/packages/patches/python-optree-fix-32-bit.patch new file mode 100644 index 0000000000..6a32c39bd8 --- /dev/null +++ b/gnu/packages/patches/python-optree-fix-32-bit.patch @@ -0,0 +1,122 @@ +In include/utils.h, ssize_t is an alias for py::ssize_t, which is an alias for +Py_ssize_t in Python, which is an alias for the system ssize_t. +The latter is defined in glibc as int if __WORDSIZE == 32 and as long int if +__WORDSIZE == 64. Therefore, we need to remove the explicit template +specialization for int in the first case. + +diff --git a/include/utils.h b/include/utils.h +index 950a02b..82a9591 100644 +--- a/include/utils.h ++++ b/include/utils.h +@@ -141,10 +141,12 @@ template <> + inline py::handle GET_ITEM_HANDLE(const py::handle& container, const size_t& item) { + return PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)); + } ++#if __WORDSIZE != 32 + template <> + inline py::handle GET_ITEM_HANDLE(const py::handle& container, const int& item) { + return PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)); + } ++#endif + template <> + inline py::handle GET_ITEM_HANDLE(const py::handle& container, const ssize_t& item) { + return PyList_GET_ITEM(container.ptr(), item); +@@ -153,10 +155,12 @@ template <> + inline py::handle GET_ITEM_HANDLE(const py::handle& container, const size_t& item) { + return PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)); + } ++#if __WORDSIZE != 32 + template <> + inline py::handle GET_ITEM_HANDLE(const py::handle& container, const int& item) { + return PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)); + } ++#endif + + template + inline py::object GET_ITEM_BORROW(const py::handle& container, const Item& item) { +@@ -171,11 +175,13 @@ inline py::object GET_ITEM_BORROW(const py::handle& container, const + return py::reinterpret_borrow( + PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#if __WORDSIZE != 32 + template <> + inline py::object GET_ITEM_BORROW(const py::handle& container, const int& item) { + return py::reinterpret_borrow( + PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#endif + template <> + inline py::object GET_ITEM_BORROW(const py::handle& container, const ssize_t& item) { + return py::reinterpret_borrow(PyList_GET_ITEM(container.ptr(), item)); +@@ -185,11 +191,13 @@ inline py::object GET_ITEM_BORROW(const py::handle& container, const s + return py::reinterpret_borrow( + PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#if __WORDSIZE != 32 + template <> + inline py::object GET_ITEM_BORROW(const py::handle& container, const int& item) { + return py::reinterpret_borrow( + PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#endif + + template + inline py::object GET_ITEM_STEAL(const py::handle& container, const Item& item) { +@@ -204,11 +212,13 @@ inline py::object GET_ITEM_STEAL(const py::handle& container, const s + return py::reinterpret_steal( + PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#if __WORDSIZE != 32 + template <> + inline py::object GET_ITEM_STEAL(const py::handle& container, const int& item) { + return py::reinterpret_steal( + PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#endif + template <> + inline py::object GET_ITEM_STEAL(const py::handle& container, const ssize_t& item) { + return py::reinterpret_steal(PyList_GET_ITEM(container.ptr(), item)); +@@ -218,11 +228,13 @@ inline py::object GET_ITEM_STEAL(const py::handle& container, const si + return py::reinterpret_steal( + PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#if __WORDSIZE != 32 + template <> + inline py::object GET_ITEM_STEAL(const py::handle& container, const int& item) { + return py::reinterpret_steal( + PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item))); + } ++#endif + + template + inline void SET_ITEM(const py::handle& container, const Item& item, const py::handle& value) { +@@ -240,12 +252,14 @@ inline void SET_ITEM(const py::handle& container, + const py::handle& value) { + PyTuple_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr()); + } ++#if __WORDSIZE != 32 + template <> + inline void SET_ITEM(const py::handle& container, + const int& item, + const py::handle& value) { + PyTuple_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr()); + } ++#endif + template <> + inline void SET_ITEM(const py::handle& container, + const ssize_t& item, +@@ -258,12 +272,14 @@ inline void SET_ITEM(const py::handle& container, + const py::handle& value) { + PyList_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr()); + } ++#if __WORDSIZE != 32 + template <> + inline void SET_ITEM(const py::handle& container, + const int& item, + const py::handle& value) { + PyList_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr()); + } ++#endif + + template + inline void AssertExact(const py::handle& object) { diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 0ac9d669d3..bac7d79af9 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -150,6 +150,7 @@ ;;; Copyright © 2024 Timothee Mathieu ;;; Copyright © 2024 Ian Eure ;;; Copyright © 2024 Adriel Dumas--Jondeau +;;; Copyright © 2024 David Elsing ;;; ;;; This file is part of GNU Guix. ;;; @@ -11741,6 +11742,35 @@ (define-public python-treelib "This package provides a Python implementation of a tree structure.") (license license:asl2.0))) +(define-public python-optree + (package + (name "python-optree") + (version "0.10.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/metaopt/optree") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1q3wljk7cyl5rsam02sfsj8zjrqx4c3x9vic8j6xx13p8czpsisg")) + (patches (search-patches "python-optree-fix-32-bit.patch")))) + (build-system pyproject-build-system) + (propagated-inputs (list python-typing-extensions)) + (native-inputs + (list python-pytest + python-pytest-cov + python-pytest-xdist + cmake + pybind11)) + (home-page "https://github.com/metaopt/optree") + (synopsis "Optimized PyTree Utilities") + (description "This package contains operations on PyTrees (a tree made of +container data structures in Python).") + (license license:asl2.0))) + (define-public python-jupyter-core (package (name "python-jupyter-core") -- 2.41.0