Skip to content

Commit

Permalink
boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Sep 20, 2024
1 parent 256fc17 commit 670ee4c
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
recursive-include actuator/ *.py *.txt py.typed MANIFEST.in
include actuator/rust/Cargo.toml
include actuator/rust/Cargo.lock
include actuator/rust/*.so
include actuator/rust/*.pyi
recursive-include actuator/rust/src *.rs
5 changes: 5 additions & 0 deletions actuator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .gitignore

# Rust
target/
Cargo.lock
4 changes: 4 additions & 0 deletions actuator/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .gitignore

*.so
*.pyi
11 changes: 11 additions & 0 deletions actuator/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "lib"
version = "0.1.0"
edition = "2021"

[lib]
name = "lib"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.17", features = ["extension-module"] }
7 changes: 7 additions & 0 deletions actuator/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use pyo3::prelude::*;

#[pymodule]
fn lib(_py: Python, _m: &PyModule) -> PyResult<()> {
println!("Hello, world!");
Ok(())
}
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ combine-as-imports = true
[tool.ruff.lint.pydocstyle]

convention = "google"

[build-system]

requires = ["setuptools>=42", "wheel", "setuptools-rust>=1.5.2"]
build-backend = "setuptools.build_meta"
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@
#!/usr/bin/env python
"""Setup script for the project."""

import os
import re
import subprocess

from setuptools import setup
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools_rust import Binding, RustExtension


class BuildExtWithStubgen(_build_ext):
def run(self) -> None:
super().run()

module_name = "actuator.rust.lib"
output_dir = os.path.dirname(__file__)
os.makedirs(output_dir, exist_ok=True)
subprocess.run(["stubgen", "-m", module_name, "-o", output_dir], check=False)


with open("README.md", "r", encoding="utf-8") as f:
long_description: str = f.read()
Expand All @@ -30,6 +45,20 @@
description="The actuator project",
author="Benjamin Bolte",
url="https://github.com/kscalelabs/actuator",
rust_extensions=[
RustExtension(
target="actuator.rust.lib",
path="actuator/rust/Cargo.toml",
binding=Binding.PyO3,
)
],
cmdclass={"build_ext": BuildExtWithStubgen},
setup_requires=[
"setuptools-rust",
"mypy", # For stubgen
],
include_package_data=True,
zip_safe=False,
long_description=long_description,
long_description_content_type="text/markdown",
python_requires=">=3.11",
Expand Down

0 comments on commit 670ee4c

Please sign in to comment.