-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust + python package first implementation
- Loading branch information
1 parent
33e9b9e
commit 0a552db
Showing
13 changed files
with
85 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[target.aarch64-apple-darwin] | ||
|
||
rustflags = [ | ||
"-C", "link-arg=-undefined", | ||
"-C", "link-arg=dynamic_lookup", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,7 @@ build/ | |
dist/ | ||
*.so | ||
out*/ | ||
|
||
# Rust | ||
target/ | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[workspace] | ||
members = [ | ||
"actuator/rust", | ||
] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
description = "Actuator Python bindings" | ||
authors = ["K-Scale Labs <[email protected]>"] | ||
repository = "https://github.com/kscalelabs/actuator" | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
[workspace.dependencies] | ||
pyo3 = { version = ">= 0.21.0", features = ["extension-module"] } | ||
pyo3-stub-gen = ">= 0.6.0" | ||
env_logger = "0.11.5" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Defines the CLI for the actuator project.""" | ||
|
||
from actuator.rust.lib import hello_world, sum | ||
|
||
|
||
def main() -> None: | ||
hello_world() | ||
print(sum([1, 2, 3, 4, 5])) | ||
|
||
|
||
if __name__ == "__main__": | ||
# python -m actuator.cli | ||
main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
[package] | ||
name = "lib" | ||
version = "0.1.0" | ||
edition = "2021" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[lib] | ||
name = "lib" | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
pyo3 = { version = "0.21", features = ["extension-module"] } | ||
pyo3-stub-gen = "0.6.0" | ||
env_logger.workspace = true | ||
pyo3-stub-gen.workspace = true | ||
pyo3.workspace = true | ||
|
||
[[bin]] | ||
name = "stub_gen" | ||
doc = false |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by pyo3_stub_gen | ||
# ruff: noqa: E501, F401 | ||
|
||
import typing | ||
|
||
def hello_world() -> None: | ||
... | ||
|
||
def sum(v:typing.Sequence[int]) -> int: | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[build-system] | ||
requires = ["maturin>=1.1,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "lib" | ||
requires-python = ">=3.9" | ||
|
||
[project.optional-dependencies] | ||
test = ["pytest", "pyright", "ruff"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use pyo3_stub_gen::Result; | ||
|
||
fn main() -> Result<()> { | ||
let stub = pure::stub_info()?; | ||
let stub = lib::stub_info()?; | ||
stub.generate()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
use pyo3::prelude::*; | ||
use pyo3_stub_gen::{define_stub_info_gatherer, derive::gen_stub_pyfunction}; | ||
|
||
#[gen_stub_pyfunction] | ||
#[pyfunction] | ||
fn hello_world() { | ||
println!("Hello, world!"); | ||
} | ||
|
||
#[gen_stub_pyfunction] | ||
#[pyfunction] | ||
fn add(a: i64, b: i64) -> i64 { | ||
a + b | ||
fn sum(v: Vec<u32>) -> u32 { | ||
v.iter().sum() | ||
} | ||
|
||
#[pymodule] | ||
fn lib(py: Python, m: &PyModule) -> PyResult<()> { | ||
fn lib(m: &Bound<PyModule>) -> PyResult<()> { | ||
m.add_function(wrap_pyfunction!(hello_world, m)?)?; | ||
m.add_function(wrap_pyfunction!(add, m)?)?; | ||
m.add_function(wrap_pyfunction!(sum, m)?)?; | ||
Ok(()) | ||
} | ||
|
||
define_stub_info_gatherer!(stub_info); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters