build_rust.py 623 B

1234567891011121314151617181920
  1. # A build script for poetry that adds the rust extension.
  2. import os
  3. from typing import Any, Dict
  4. from setuptools_rust import Binding, RustExtension
  5. def build(setup_kwargs: Dict[str, Any]) -> None:
  6. original_project_dir = os.path.dirname(os.path.realpath(__file__))
  7. cargo_toml_path = os.path.join(original_project_dir, "rust", "Cargo.toml")
  8. extension = RustExtension(
  9. target="synapse.synapse_rust",
  10. path=cargo_toml_path,
  11. binding=Binding.PyO3,
  12. py_limited_api=True,
  13. )
  14. setup_kwargs.setdefault("rust_extensions", []).append(extension)
  15. setup_kwargs["zip_safe"] = False