Skip to content

Commit ace4118

Browse files
author
Martin Larralde
committed
Add an example for tomlgen_rust features
1 parent 7951200 commit ace4118

File tree

7 files changed

+77
-0
lines changed

7 files changed

+77
-0
lines changed

example_tomlgen/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
Cargo.toml
3+
Cargo.lock

example_tomlgen/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
`example_tomlgen`
2+
=================
3+
4+
An example extensions with automatically generated ``Cargo.toml`` manifest
5+
files.

example_tomlgen/hello/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# coding: utf-8
2+
3+
from . import french
4+
from . import english

example_tomlgen/hello/english/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(proc_macro)]
2+
3+
extern crate pyo3;
4+
5+
use pyo3::prelude::*;
6+
7+
/// Module documentation string
8+
#[py::modinit(english)]
9+
fn init(py: Python, m: &PyModule) -> PyResult<()> {
10+
11+
#[pyfn(m, "hello")]
12+
fn hello(_py: Python) -> PyResult<()> {
13+
println!("Hello, world!");
14+
Ok(())
15+
}
16+
17+
Ok(())
18+
}

example_tomlgen/hello/french/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(proc_macro)]
2+
3+
extern crate pyo3;
4+
5+
use pyo3::prelude::*;
6+
7+
/// Module documentation string
8+
#[py::modinit(french)]
9+
fn init(py: Python, m: &PyModule) -> PyResult<()> {
10+
11+
#[pyfn(m, "hello")]
12+
fn hello(_py: Python) -> PyResult<()> {
13+
println!("Bonjour, monde!");
14+
Ok(())
15+
}
16+
17+
Ok(())
18+
}

example_tomlgen/setup.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[metadata]
2+
author_email = "[email protected]"
3+
4+
[tomlgen_rust]
5+
create_workspace = true
6+
7+
[tomlgen_rust.dependencies]
8+
pyo3 = { version = "*", features = ["extension-module"] }
9+
10+
[aliases]
11+
build_rust = tomlgen build_rust

example_tomlgen/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import setuptools
2+
import setuptools_rust as rust
3+
4+
5+
setuptools.setup(
6+
name='hello-rust',
7+
version='0.1.0',
8+
author="Martin Larralde",
9+
10+
# Find all inplace extensions
11+
rust_extensions=rust.find_rust_extensions(
12+
binding=rust.Binding.PyO3,
13+
strip=rust.Strip.Debug,
14+
),
15+
16+
# rust extensions are not zip safe, just like C-extensions.
17+
zip_safe=False
18+
)

0 commit comments

Comments
 (0)