mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
Initial binding infrastructure
This commit is contained in:
parent
2b68c899b2
commit
0e312a9d28
13
crates/servicepoint_binding_py/Cargo.toml
Normal file
13
crates/servicepoint_binding_py/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "servicepoint_binding_py"
|
||||
metadata.maturin.name = "servicepoint"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[lib]
|
||||
name = "servicepoint_binding_py"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
pyo3 = "0.21.1"
|
6
crates/servicepoint_binding_py/Makefile
Normal file
6
crates/servicepoint_binding_py/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
.phony:
|
||||
build:
|
||||
cargo build
|
||||
pip uninstall -y servicepoint
|
||||
pip install --editable .
|
||||
python -c "import servicepoint as s; print(dir(s)); print(dir(s.rust_bindings))"
|
0
crates/servicepoint_binding_py/Readme.md
Normal file
0
crates/servicepoint_binding_py/Readme.md
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
17
crates/servicepoint_binding_py/pyproject.toml
Normal file
17
crates/servicepoint_binding_py/pyproject.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[build-system]
|
||||
requires = ["maturin>=1.6,<2.0"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "servicepoint"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[tool.maturin]
|
||||
module-name = "servicepoint.rust_bindings"
|
||||
features = ["pyo3/extension-module"]
|
1
crates/servicepoint_binding_py/servicepoint/.gitignore
vendored
Normal file
1
crates/servicepoint_binding_py/servicepoint/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.so
|
5
crates/servicepoint_binding_py/servicepoint/__init__.py
Normal file
5
crates/servicepoint_binding_py/servicepoint/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from . import rust_bindings
|
||||
|
||||
__doc__ = rust_bindings.__doc__
|
||||
if hasattr(rust_bindings, "__all__"):
|
||||
__all__ = rust_bindings.__all__
|
16
crates/servicepoint_binding_py/src/lib.rs
Normal file
16
crates/servicepoint_binding_py/src/lib.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use pyo3::prelude::*;
|
||||
|
||||
/// Formats the sum of two numbers as string.
|
||||
#[pyfunction]
|
||||
#[pyo3(name = "fnord")]
|
||||
pub fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
|
||||
Ok((a + b).to_string())
|
||||
}
|
||||
|
||||
/// A Python module implemented in Rust.
|
||||
#[pymodule]
|
||||
#[pyo3(name = "rust_bindings")]
|
||||
fn servicepoint_binding_py(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue