build_rust.py 791 B

1234567891011121314151617181920212223
  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. # We force always building in release mode, as we can't tell the
  14. # difference between using `poetry` in development vs production.
  15. debug=False,
  16. )
  17. setup_kwargs.setdefault("rust_extensions", []).append(extension)
  18. setup_kwargs["zip_safe"] = False