[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#69591] [PATCH v4 03/32] gnu: Add python-optree.
From: |
David Elsing |
Subject: |
[bug#69591] [PATCH v4 03/32] gnu: Add python-optree. |
Date: |
Sat, 23 Mar 2024 22:04:42 +0000 |
* 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<py::tuple>(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<py::tuple>(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<py::list>(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<py::list>(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<py::list>(const py::handle& container,
const int& item) {
+ return PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item));
+ }
++#endif
+
+ template <typename Container, typename Item>
+ inline py::object GET_ITEM_BORROW(const py::handle& container, const Item&
item) {
+@@ -171,11 +175,13 @@ inline py::object GET_ITEM_BORROW<py::tuple>(const
py::handle& container, const
+ return py::reinterpret_borrow<py::object>(
+ PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#if __WORDSIZE != 32
+ template <>
+ inline py::object GET_ITEM_BORROW<py::tuple>(const py::handle& container,
const int& item) {
+ return py::reinterpret_borrow<py::object>(
+ PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#endif
+ template <>
+ inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container,
const ssize_t& item) {
+ return
py::reinterpret_borrow<py::object>(PyList_GET_ITEM(container.ptr(), item));
+@@ -185,11 +191,13 @@ inline py::object GET_ITEM_BORROW<py::list>(const
py::handle& container, const s
+ return py::reinterpret_borrow<py::object>(
+ PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#if __WORDSIZE != 32
+ template <>
+ inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container,
const int& item) {
+ return py::reinterpret_borrow<py::object>(
+ PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#endif
+
+ template <typename Container, typename Item>
+ inline py::object GET_ITEM_STEAL(const py::handle& container, const Item&
item) {
+@@ -204,11 +212,13 @@ inline py::object GET_ITEM_STEAL<py::tuple>(const
py::handle& container, const s
+ return py::reinterpret_steal<py::object>(
+ PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#if __WORDSIZE != 32
+ template <>
+ inline py::object GET_ITEM_STEAL<py::tuple>(const py::handle& container,
const int& item) {
+ return py::reinterpret_steal<py::object>(
+ PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#endif
+ template <>
+ inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const
ssize_t& item) {
+ return py::reinterpret_steal<py::object>(PyList_GET_ITEM(container.ptr(),
item));
+@@ -218,11 +228,13 @@ inline py::object GET_ITEM_STEAL<py::list>(const
py::handle& container, const si
+ return py::reinterpret_steal<py::object>(
+ PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#if __WORDSIZE != 32
+ template <>
+ inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const
int& item) {
+ return py::reinterpret_steal<py::object>(
+ PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
+ }
++#endif
+
+ template <typename Container, typename Item>
+ inline void SET_ITEM(const py::handle& container, const Item& item, const
py::handle& value) {
+@@ -240,12 +252,14 @@ inline void SET_ITEM<py::tuple>(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<py::tuple>(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<py::list>(const py::handle& container,
+ const ssize_t& item,
+@@ -258,12 +272,14 @@ inline void SET_ITEM<py::list>(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<py::list>(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 <typename PyType>
+ inline void AssertExact(const py::handle& object) {
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index aad89d251e..5357c94b8c 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -150,6 +150,7 @@
;;; Copyright © 2024 Timothee Mathieu <timothee.mathieu@inria.fr>
;;; Copyright © 2024 Ian Eure <ian@retrospec.tv>
;;; Copyright © 2024 Adriel Dumas--Jondeau <leirda@disroot.org>
+;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
;;;
;;; 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
- [bug#69591] [PATCH v4 29/32] gnu: Add ideep-pytorch-for-r-torch., (continued)
- [bug#69591] [PATCH v4 29/32] gnu: Add ideep-pytorch-for-r-torch., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 02/32] gnu: Add python-typing-extensions-4.10., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 07/32] gnu: Add python-pytest-rerunfailures-13., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 15/32] gnu: clog: Add "-DUSE_SYSTEM_LIBS=ON" configure flag., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 10/32] gnu: Add libnop., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 12/32] gnu: python-flatbuffers-next: Update to 23.5.26., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 23/32] gnu: xnnpack: Update to commit 51a9875., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 32/32] gnu: python-pytorch-for-r-torch: Adjust to new python-pytorch., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 11/32] gnu: Remove flatbuffers-next-shared., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 09/32] gnu: Add miniz-for-pytorch., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 03/32] gnu: Add python-optree.,
David Elsing <=
- [bug#69591] [PATCH v4 26/32] gnu: python-pytorch: Update to 2.2.1 and unbundle dependencies., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 14/32] gnu: cpuinfo: Update to commit aa4b216., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 01/32] gnu: asmjit: Update to commit 3ca5c18., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 06/32] gnu: Add python-expecttest., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 04/32] gnu: Add python-pytest-flakefinder., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 13/32] gnu: pthreadpool: Update to commit 178e3e0., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 08/32] gnu: Add miniz., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 17/32] gnu: oneapi-dnnl: Update to 3.3.5., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 05/32] gnu: Add python-pytest-shard., David Elsing, 2024/03/23
- [bug#69591] [PATCH v4 18/32] gnu: Add tensorpipe., David Elsing, 2024/03/23