mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
gnu: Add python-optree.
* gnu/packages/python-xyz.scm (python-optree): New variable. * gnu/packages/patches/python-optree-fix-32-bit.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Change-Id: I37e38ef9da5e7459c8faf2c3494e2e0c0aedbfff
This commit is contained in:
parent
b452dd635f
commit
7e3a2272e1
3 changed files with 153 additions and 0 deletions
|
@ -1953,6 +1953,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/python-hiredis-fix-header.patch \
|
||||
%D%/packages/patches/python-hiredis-use-system-hiredis.patch \
|
||||
%D%/packages/patches/python-online-judge-api-client-tests.patch \
|
||||
%D%/packages/patches/python-optree-fix-32-bit.patch \
|
||||
%D%/packages/patches/python-pdoc3-tests.patch \
|
||||
%D%/packages/patches/python-peachpy-determinism.patch \
|
||||
%D%/packages/patches/python-pep8-stdlib-tokenize-compat.patch \
|
||||
|
|
122
gnu/packages/patches/python-optree-fix-32-bit.patch
Normal file
122
gnu/packages/patches/python-optree-fix-32-bit.patch
Normal file
|
@ -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) {
|
|
@ -152,6 +152,7 @@
|
|||
;;; Copyright © 2024 Adriel Dumas--Jondeau <leirda@disroot.org>
|
||||
;;; Copyright © 2024 Navid Afkhami <navid.afkhami@mdc-berlin.de>
|
||||
;;; Copyright © 2024 TakeV <takev@disroot.org>
|
||||
;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -12213,6 +12214,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")
|
||||
|
|
Loading…
Reference in a new issue