From 03a381787857d2f07995aee9d207a75ae9697063 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 12 May 2017 23:01:54 -0700 Subject: [PATCH] update readme and travis --- .travis.yml | 2 +- Makefile | 7 +------ README.md | 4 ++-- src/lib.rs | 18 ++++++++---------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85cc19a1..abafdb7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,4 +19,4 @@ install: - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib" - rustc -V script: - - make test extensions + - make test diff --git a/Makefile b/Makefile index f151c7ae..8cf54eac 100644 --- a/Makefile +++ b/Makefile @@ -39,15 +39,11 @@ endif doc: build cargo doc --no-deps $(CARGO_FLAGS) -extensions: build - make -C extensions/tests PY=$(PY) - clean: rm -r target - make -C extensions/ clean gh-pages: - git clone --branch gh-pages git@github.com:dgrunwald/rust-cpython.git gh-pages + git clone --branch gh-pages git@github.com:PyO3/PyO3.git gh-pages .PHONY: gh-pages-doc gh-pages-doc: doc | gh-pages @@ -61,4 +57,3 @@ gh-pages-doc: doc | gh-pages publish: default gh-pages-doc cargo publish cd gh-pages && git push - diff --git a/README.md b/README.md index 3c195b0f..864b229f 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,13 @@ features = ["extension-module"] **`src/lib.rs`** ```rust -#[macro_use] extern crate pye3; +#[macro_use] extern crate pyo3; use pyo3::{PyResult, Python}; // add bindings to the generated python module // N.B: names: "librust2py" must be the name of the `.so` or `.pyd` file -py_module_initializer!(librust2py, PyInit_librust2py, |py, m| { +py_module_init!(librust2py, PyInit_librust2py, |py, m| { try!(m.add(py, "__doc__", "This module is implemented in Rust.")); try!(m.add(py, "sum_as_string", py_fn!(py, sum_as_string_py(a: i64, b:i64)))); Ok(()) diff --git a/src/lib.rs b/src/lib.rs index d3f21ceb..1f1d5433 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -173,7 +173,6 @@ mod pythonrun; pub mod argparse; mod function; pub mod buffer; -//pub mod rustobject; pub mod py_class; /// Private re-exports for macros. Do not use. @@ -196,8 +195,7 @@ pub mod _detail { /// Macro syntax: `py_module_initializer!($name, $py2_init, $py3_init, |$py, $m| $body)` /// /// 1. `name`: The module name as a Rust identifier. -/// 2. `py2_init`: "init" + $name. Necessary because macros can't use concat_idents!(). -/// 3. `py3_init`: "PyInit_" + $name. Necessary because macros can't use concat_idents!(). +/// 2. `py3_init`: "PyInit_" + $name. Necessary because macros can't use concat_idents!(). /// 4. A lambda of type `Fn(Python, &PyModule) -> PyResult<()>`. /// This function will be called when the module is imported, and is responsible /// for adding the module's members. @@ -207,7 +205,7 @@ pub mod _detail { /// #[macro_use] extern crate pyo3; /// use pyo3::{Python, PyResult, PyObject}; /// -/// py_module_initializer!(hello, PyInit_hello, |py, m| { +/// py_module_init!(hello, PyInit_hello, |py, m| { /// m.add(py, "__doc__", "Module documentation string")?; /// m.add(py, "run", py_fn!(py, run()))?; /// Ok(()) @@ -246,7 +244,7 @@ pub mod _detail { /// ``` /// #[macro_export] -macro_rules! py_module_initializer { +macro_rules! py_module_init { ($name: ident, $py3: ident, |$py_id: ident, $m_id: ident| $body: expr) => { #[no_mangle] #[allow(non_snake_case)] @@ -259,17 +257,17 @@ macro_rules! py_module_initializer { // We can't convert &'static str to *const c_char within a static initializer, // so we'll do it here in the module initialization: MODULE_DEF.m_name = concat!(stringify!($name), "\0").as_ptr() as *const _; - $crate::py_module_initializer_impl(&mut MODULE_DEF, init) + $crate::py_module_init_impl(&mut MODULE_DEF, init) } } } #[doc(hidden)] -pub unsafe fn py_module_initializer_impl( +pub unsafe fn py_module_init_impl( def: *mut ffi::PyModuleDef, - init: fn(Python, &PyModule) -> PyResult<()> -) -> *mut ffi::PyObject { - let guard = function::AbortOnDrop("py_module_initializer"); + init: fn(Python, &PyModule) -> PyResult<()>) -> *mut ffi::PyObject +{ + let guard = function::AbortOnDrop("py_module_init"); let py = Python::assume_gil_acquired(); ffi::PyEval_InitThreads(); let module = ffi::PyModule_Create(def);