diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..24b2fe3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "pyo3bug" +version = "0.1.0" +authors = ["Manuel Vázquez Acosta "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +name = "pyo3bug" +crate-type = ["cdylib"] + + +[dependencies.pyo3] +git = "https://github.com/PyO3/pyo3" +features = ["extension-module", "python3"] diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..960db9d --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,26 @@ +use pyo3::prelude::*; + +#[pymodule] +fn pyo3bug(_py: Python, _m: &PyModule) -> PyResult<()> { + Ok(()) +} + +#[cfg(test)] +mod test { + use super::*; + use pyo3::types::{IntoPyDict, PyDateTime}; + + #[test] + fn pydelta_conversion() { + let gil = Python::acquire_gil(); + let py = gil.python(); + let datetime = py.import("datetime").unwrap(); + let locals = [("datetime", datetime)].into_py_dict(py); + let now: &PyDateTime = py + .eval("datetime.datetime.utcnow()", None, Some(&locals)) + .unwrap() + .downcast() + .unwrap(); + println!("{:?}", now); + } +}