summary refs log tree commit diff
path: root/build_rust.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-09-06 19:01:37 +0100
committerGitHub <noreply@github.com>2022-09-06 19:01:37 +0100
commitc9b7e9735508bb148c6ad59c433d71e5b8b360ad (patch)
tree57ddf5996b62da73f12647f3b537f9843e4e8331 /build_rust.py
parentFix trial-olddeps (#13725) (diff)
downloadsynapse-c9b7e9735508bb148c6ad59c433d71e5b8b360ad.tar.xz
Add a stub Rust crate (#12595)
Diffstat (limited to 'build_rust.py')
-rw-r--r--build_rust.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/build_rust.py b/build_rust.py
new file mode 100644
index 0000000000..5c5e557ee8
--- /dev/null
+++ b/build_rust.py
@@ -0,0 +1,20 @@
+# A build script for poetry that adds the rust extension.
+
+import os
+from typing import Any, Dict
+
+from setuptools_rust import Binding, RustExtension
+
+
+def build(setup_kwargs: Dict[str, Any]) -> None:
+    original_project_dir = os.path.dirname(os.path.realpath(__file__))
+    cargo_toml_path = os.path.join(original_project_dir, "rust", "Cargo.toml")
+
+    extension = RustExtension(
+        target="synapse.synapse_rust",
+        path=cargo_toml_path,
+        binding=Binding.PyO3,
+        py_limited_api=True,
+    )
+    setup_kwargs.setdefault("rust_extensions", []).append(extension)
+    setup_kwargs["zip_safe"] = False