python-orjson/Use-setuptools-rust-instead-of-maturin.patch

81 lines
2.2 KiB
Diff

From 37abb055e3435406156c6e4462b2a58923c9f11a Mon Sep 17 00:00:00 2001
From: Maxwell G <gotmax@e.email>
Date: Wed, 25 Jan 2023 13:47:35 -0600
Subject: [PATCH] Use setuptools-rust instead of maturin
Maturin is not packaged for Fedora. We can use setuptools-rust instead.
This requires setutpools >= 61.0 which is available on F37+. The
metadata in the [project] table can be translated to a setup.cfg or
added to setup.py for greater compatibility.
---
pyproject.toml | 9 ++++++---
setup.py | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
create mode 100644 setup.py
diff --git a/pyproject.toml b/pyproject.toml
index 8372fc8..1e48b88 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,5 @@
[project]
name = "orjson"
-repository = "https://github.com/ijl/orjson"
requires-python = ">=3.7"
classifiers = [
"Development Status :: 5 - Production/Stable",
@@ -22,10 +21,14 @@ classifiers = [
"Programming Language :: Rust",
"Typing :: Typed",
]
+dynamic = [
+ # version is dynamically defined in setup.py
+ "version",
+]
[build-system]
-build-backend = "maturin"
-requires = ["maturin>=0.13,<2"]
+build-backend = "setuptools.build_meta"
+requires = ["setuptools>=61.0", "setuptools-rust", "tomli; python_version<'3.11'"]
[tool.maturin]
python-source = "pysrc"
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..63f263d
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,28 @@
+import sys
+from pathlib import Path
+
+if sys.version_info[:2] >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
+from setuptools import setup
+from setuptools_rust import Binding, RustExtension
+
+HERE = Path(__file__).resolve().parent
+
+with (HERE / "Cargo.toml").open("rb") as fp:
+ DATA = tomllib.load(fp)["package"]
+
+setup(
+ # Can be removed once we no longer need a minimal build for setuptools < 61.
+ # This is duplicated in pyproject.toml's [project] table
+ name="orjson",
+ packages=["orjson"],
+ #
+ rust_extensions=[
+ RustExtension("orjson.orjson", binding=Binding.NoBinding, args=["--offline"])
+ ],
+ package_dir={"": "pysrc"},
+ version=DATA["version"],
+)
--
2.40.1