Skip to content

Commit 7a7302c

Browse files
author
Martin Larralde
committed
Fix compilation issues with pyo3 v0.6
1 parent dca1a01 commit 7a7302c

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

example_tomlgen/hello/english/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
#[macro_use]
12
extern crate pyo3;
23

34
use pyo3::prelude::*;
45

5-
/// Module documentation string
6-
#[pymodinit]
7-
fn english(_py: Python, m: &PyModule) -> PyResult<()> {
6+
#[pyfunction]
7+
fn hello(_py: Python) -> PyResult<()> {
8+
println!("Hello, world!");
9+
Ok(())
10+
}
811

9-
#[pyfn(m, "hello")]
10-
fn hello(_py: Python) -> PyResult<()> {
11-
println!("Hello, world!");
12-
Ok(())
13-
}
1412

13+
#[pymodule]
14+
/// Module documentation string
15+
fn english(_py: Python, m: &PyModule) -> PyResult<()> {
16+
m.add_wrapped(wrap_function!(hello))?;
1517
Ok(())
1618
}

example_tomlgen/hello/french/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
#[macro_use]
12
extern crate pyo3;
23

34
use pyo3::prelude::*;
45

5-
/// Module documentation string
6-
#[pymodinit]
7-
fn french(_py: Python, m: &PyModule) -> PyResult<()> {
6+
#[pyfunction]
7+
fn hello(_py: Python) -> PyResult<()> {
8+
println!("Bonjour, monde!");
9+
Ok(())
10+
}
811

9-
#[pyfn(m, "hello")]
10-
fn hello(_py: Python) -> PyResult<()> {
11-
println!("Bonjour, monde!");
12-
Ok(())
13-
}
1412

13+
#[pymodule]
14+
/// Module documentation string
15+
fn french(_py: Python, m: &PyModule) -> PyResult<()> {
16+
m.add_wrapped(wrap_function!(hello))?;
1517
Ok(())
1618
}

example_tomlgen/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ zip_safe = false
1010
create_workspace = true
1111

1212
[tomlgen_rust.dependencies]
13-
pyo3 = { version = "0.5.0-alpha.3", features = ["extension-module"] }
13+
pyo3 = { version = "0.6.0-alpha", features = ["extension-module"] }
1414

1515
[tomlgen_rust.dependencies.hello-english]
1616
english-lint = "*"

html-py-ever/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["konstin <[email protected]>"]
55

66
[dependencies]
77
kuchiki = "0.7.2"
8-
pyo3 = {git = "https://github.com/PyO3/pyo3", features = ["extension-module"]}
8+
pyo3 = { version = "0.6.0-alpha", features = ["extension-module"]}
99
tendril = "0.4.0"
1010

1111
[lib]

html-py-ever/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ fn parse_text(text: &str) -> PyResult<Document> {
5555
Ok(document)
5656
}
5757

58-
#[pymodinit]
58+
#[pymodule]
5959
fn html_py_ever(_py: Python, m: &PyModule) -> PyResult<()> {
60-
m.add_function(wrap_function!(parse_file))?;
61-
m.add_function(wrap_function!(parse_text))?;
60+
m.add_wrapped(wrap_function!(parse_file))?;
61+
m.add_wrapped(wrap_function!(parse_text))?;
6262
m.add_class::<Document>()?;
6363

6464
Ok(())

0 commit comments

Comments
 (0)