python-rpds-py: Add new package
authorJeffery To <jeffery.to@gmail.com>
Fri, 13 Oct 2023 18:14:10 +0000 (02:14 +0800)
committerTianling Shen <cnsztl@gmail.com>
Thu, 30 Nov 2023 04:57:27 +0000 (12:57 +0800)
From the README:

Python bindings to the Rust rpds crate for persistent data structures.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python-rpds-py/Makefile [new file with mode: 0644]
lang/python/python-rpds-py/test.sh [new file with mode: 0644]

diff --git a/lang/python/python-rpds-py/Makefile b/lang/python/python-rpds-py/Makefile
new file mode 100644 (file)
index 0000000..c2aef84
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2023 Jeffery To
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=python-rpds-py
+PKG_VERSION:=0.10.6
+PKG_RELEASE:=1
+
+PYPI_NAME:=rpds-py
+PYPI_SOURCE_NAME:=rpds_py
+PKG_HASH:=4ce5a708d65a8dbf3748d2474b580d606b1b9f91b5c6ab2a316e0b0cf7a4ba50
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+
+PKG_BUILD_DEPENDS:=python-maturin/host
+
+include ../pypi.mk
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-rpds-py
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Python
+  TITLE:=Bindings to Rust's persistent data structures
+  URL:=https://github.com/crate-py/rpds
+  DEPENDS:=+python3-light $(RUST_ARCH_DEPENDS)
+endef
+
+define Package/python3-rpds-py/description
+Python bindings to the Rust rpds crate for persistent data structures.
+endef
+
+$(eval $(call Py3Package,python3-rpds-py))
+$(eval $(call BuildPackage,python3-rpds-py))
+$(eval $(call BuildPackage,python3-rpds-py-src))
diff --git a/lang/python/python-rpds-py/test.sh b/lang/python/python-rpds-py/test.sh
new file mode 100644 (file)
index 0000000..d5dec8f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+[ "$1" = python3-rpds-py ] || exit 0
+
+python3 - << 'EOF'
+
+from rpds import HashTrieMap, HashTrieSet, List
+
+m = HashTrieMap({"foo": "bar", "baz": "quux"})
+assert m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37})
+assert m.remove("foo") == HashTrieMap({"baz": "quux"})
+
+s = HashTrieSet({"foo", "bar", "baz", "quux"})
+assert s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"})
+assert s.remove("foo") == HashTrieSet({"bar", "baz", "quux"})
+
+L = List([1, 3, 5])
+assert L.push_front(-1) == List([-1, 1, 3, 5])
+assert L.rest == List([3, 5])
+
+EOF