Skip to contentSkip to conversation

package/python-orjson: new package

Buildroot Applied Graeme Smecher 2 participants 3 messages Apr 19, 2022 – May 3, 2022

lore
Share & tools
lore
#0 lore raw

The python-orjson package is: [1]

"[...] a fast, correct JSON library for Python. It benchmarks as the fastest Python library for JSON and is more correct than the standard json library or other third-party libraries. It serializes dataclass, datetime, numpy, and UUID instances natively."

For buildroot (at least for my purposes), the ability to efficiently serialize numpy arrays is the distinguishing feature from other Python JSON libraries (of which, simplejson, json, and ujson are already packaged here.)

1: https://pypi.org/project/orjson/

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw

PATCH 1/1 Adds python-orjson support.

---
 DEVELOPERS                               |  3 +++
 package/Config.in                        |  1 +
 package/python-orjson/Config.in          | 12 ++++++++++++
 package/python-orjson/python-orjson.hash |  3 +++
 package/python-orjson/python-orjson.mk   | 22 ++++++++++++++++++++++
 5 files changed, 41 insertions(+)
 create mode 100644 package/python-orjson/Config.in
 create mode 100644 package/python-orjson/python-orjson.hash
 create mode 100644 package/python-orjson/python-orjson.mk
DEVELOPERS +3 -0
index ca9decb58f..0846aac835 100644
@@ -3058,3 +3058,6 @@ F:	package/quazip/
 F:	package/shapelib/
 F:	package/simple-mail/
 F:	package/tinc/
+
+N:	Graeme Smecher <[email protected]>
+F:	package/python-orjson/
package/Config.in +1 -0
index c599271c65..1494387c2e 100644
@@ -1111,6 +1111,7 @@ menu "External python modules"
 	source "package/python-numpy/Config.in"
 	source "package/python-oauthlib/Config.in"
 	source "package/python-opcua-asyncio/Config.in"
+	source "package/python-orjson/Config.in"
 	source "package/python-packaging/Config.in"
 	source "package/python-paho-mqtt/Config.in"
 	source "package/python-paramiko/Config.in"
package/python-orjson/Config.in new file +12 -0
new file mode 100644
index 0000000000..fa96eee57d
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_PYTHON_ORJSON
+	bool "python-orjson"
+	depends on BR2_PACKAGE_PYTHON3
+	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+	select BR2_PACKAGE_PYTHON_CFFI # runtime
+	help
+	  orjson is a fast, correct JSON library for Python. It benchmarks as
+	  the fastest Python library for JSON and is more correct than the
+	  standard json library or other third-party libraries. It serializes
+	  dataclass, datetime, numpy, and UUID instances natively.
+
+	  https://github.com/ijl/orjson
package/python-orjson/python-orjson.hash new file +3 -0
new file mode 100644
index 0000000000..8f9cc2a7c9
@@ -0,0 +1,3 @@
+sha256  4713b120ad86b1b273f5952cbf9578c13d0f453064bd26d823e04a10c84824e6  python-orjson-3.6.7.tar.gz
+sha256  a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256  23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
package/python-orjson/python-orjson.mk new file +22 -0
new file mode 100644
index 0000000000..5de4b2c5fa
@@ -0,0 +1,22 @@
+################################################################################
+#
+# python-orjson
+#
+################################################################################
+
+PYTHON_ORJSON_VERSION = 3.6.7
+PYTHON_ORJSON_SITE = $(call github,ijl,orjson,$(PYTHON_ORJSON_VERSION))
+PYTHON_ORJSON_LICENSE = Apache-2.0 or MIT
+PYTHON_ORJSON_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+PYTHON_ORJSON_DEPENDENCIES = host-python-cffi
+PYTHON_ORJSON_CARGO_ENV = \
+	PYO3_CROSS_LIB_DIR="$(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)"
+
+# orjson uses "maturin" to generate distribution packages - rather than teach
+# buildroot how to understand this, we reach in and install directly.
+define PYTHON_ORJSON_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(@D)/target/$(RUSTC_TARGET_NAME)/release/liborjson.so \
+		$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/orjson.so
+endef
+
+$(eval $(cargo-package))
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH] Adds python-orjson support.

The commit message should have been like this:

package/python-orjson: new package

Quoted 16 lines · Graeme Smecher
---
  DEVELOPERS                               |  3 +++
  package/Config.in                        |  1 +
  package/python-orjson/Config.in          | 12 ++++++++++++
  package/python-orjson/python-orjson.hash |  3 +++
  package/python-orjson/python-orjson.mk   | 22 ++++++++++++++++++++++
  5 files changed, 41 insertions(+)

create mode 100644 package/python-orjson/Config.in create mode 100644 package/python-orjson/python-orjson.hash create mode 100644 package/python-orjson/python-orjson.mk

DEVELOPERS +0 -0
index ca9decb58f..0846aac835 100644

DEVELOPERS F: package/quazip/ · line 3062

Quoted 5 lines
DEVELOPERS +2 -0
@@ -3058,3 +3058,6 @@ F:	package/quazip/
  F:	package/shapelib/
  F:	package/simple-mail/
  F:	package/tinc/
+
+N:	Graeme Smecher <[email protected]>

This should have been alphabetic.

Quoted 19 lines
DEVELOPERS +1 -0
+F:	package/python-orjson/
package/Config.in +1 -0
index c599271c65..1494387c2e 100644
@@ -1111,6 +1111,7 @@ menu "External python modules"
  	source "package/python-numpy/Config.in"
  	source "package/python-oauthlib/Config.in"
  	source "package/python-opcua-asyncio/Config.in"
+	source "package/python-orjson/Config.in"
  	source "package/python-packaging/Config.in"
  	source "package/python-paho-mqtt/Config.in"
  	source "package/python-paramiko/Config.in"
package/python-orjson/Config.in new file +0 -0
new file mode 100644
index 0000000000..fa96eee57d

package/python-orjson/Config.in line 7

Quoted 7 lines
package/python-orjson/Config.in new file +7 -0
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_PYTHON_ORJSON
+	bool "python-orjson"
+	depends on BR2_PACKAGE_PYTHON3
+	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+	select BR2_PACKAGE_PYTHON_CFFI # runtime
+	help
+	  orjson is a fast, correct JSON library for Python. It benchmarks as

Wrap at 72 columns (the tab counts for 8). utils/check-package warns about this.

Applied to master with those things fixed, thanks.

Regards,
Arnout

Quoted 32 lines
package/python-orjson/Config.in new file +5 -0
+	  the fastest Python library for JSON and is more correct than the
+	  standard json library or other third-party libraries. It serializes
+	  dataclass, datetime, numpy, and UUID instances natively.
+
+	  https://github.com/ijl/orjson
package/python-orjson/python-orjson.hash new file +3 -0
new file mode 100644
index 0000000000..8f9cc2a7c9
@@ -0,0 +1,3 @@
+sha256  4713b120ad86b1b273f5952cbf9578c13d0f453064bd26d823e04a10c84824e6  python-orjson-3.6.7.tar.gz
+sha256  a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2  LICENSE-APACHE
+sha256  23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3  LICENSE-MIT
package/python-orjson/python-orjson.mk new file +12 -0
new file mode 100644
index 0000000000..5de4b2c5fa
@@ -0,0 +1,22 @@
+################################################################################
+#
+# python-orjson
+#
+################################################################################
+
+PYTHON_ORJSON_VERSION = 3.6.7
+PYTHON_ORJSON_SITE = $(call github,ijl,orjson,$(PYTHON_ORJSON_VERSION))
+PYTHON_ORJSON_LICENSE = Apache-2.0 or MIT
+PYTHON_ORJSON_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+PYTHON_ORJSON_DEPENDENCIES = host-python-cffi
+PYTHON_ORJSON_CARGO_ENV = \

package/python-orjson/python-orjson.mk line 22

Quoted 10 lines
package/python-orjson/python-orjson.mk new file +10 -0
+	PYO3_CROSS_LIB_DIR="$(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)"
+
+# orjson uses "maturin" to generate distribution packages - rather than teach
+# buildroot how to understand this, we reach in and install directly.
+define PYTHON_ORJSON_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(@D)/target/$(RUSTC_TARGET_NAME)/release/liborjson.so \
+		$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/orjson.so
+endef
+
+$(eval $(cargo-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot