diff --git a/.gitignore b/.gitignore index 208da74a..87452b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ __pycache__/ .cache .pytest_cache/ dist/ +.tox/ +.mypy_cache/ +.hypothesis/ *.so *.out diff --git a/README.md b/README.md index d6dccc38..272bf2bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Build Status](https://travis-ci.org/PyO3/pyo3.svg?branch=master)](https://travis-ci.org/PyO3/pyo3) [![Build Status](https://ci.appveyor.com/api/projects/status/github/PyO3/pyo3?branch=master&svg=true)](https://ci.appveyor.com/project/fafhrd91/pyo3) -[![codecov](https://codecov.io/gh/PyO3/pyo3/branch/master/graph/badge.svg)](https://codecov.io/gh/PyO3/pyo3) [![crates.io](http://meritbadge.herokuapp.com/pyo3)](https://crates.io/crates/pyo3) [![Join the dev chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/PyO3/Lobby) diff --git a/examples/rustapi_module/.gitignore b/examples/rustapi_module/.gitignore deleted file mode 100644 index 7a6ac170..00000000 --- a/examples/rustapi_module/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.pytest_cache -.mypy_cache -.hypothesis -.tox - -*.py[co] diff --git a/examples/word-count/README.md b/examples/word-count/README.md index 0cd326fe..ff74b7de 100644 --- a/examples/word-count/README.md +++ b/examples/word-count/README.md @@ -24,4 +24,12 @@ There is a benchmark in `tests/test_word_count.py`: ```shell pytest -v tests +``` + +## Testing + +To test python 2.7, 3.5, 3.6 and 3.7, install tox globally and run + +```shell +tox ``` \ No newline at end of file diff --git a/examples/word-count/requirements-dev.txt b/examples/word-count/requirements-dev.txt new file mode 100644 index 00000000..f55c7ca8 --- /dev/null +++ b/examples/word-count/requirements-dev.txt @@ -0,0 +1,3 @@ +pytest>=3.5.0 +setuptools-rust>=0.10.2 +pytest-benchmark>=3.1.1 diff --git a/examples/word-count/src/lib.rs b/examples/word-count/src/lib.rs index 166d8f30..5785a181 100644 --- a/examples/word-count/src/lib.rs +++ b/examples/word-count/src/lib.rs @@ -11,8 +11,8 @@ use rayon::prelude::*; use std::fs; use std::path::PathBuf; -#[pyclass] /// Represents a file that can be searched +#[pyclass] struct WordCounter { path: PathBuf, } @@ -66,8 +66,8 @@ fn matches(word: &str, needle: &str) -> bool { return needle.next().is_none(); } -#[pyfunction] /// Count the occurences of needle in line, case insensitive +#[pyfunction] fn count_line(line: &str, needle: &str) -> usize { let mut total = 0; for word in line.split(' ') { diff --git a/examples/word-count/tox.ini b/examples/word-count/tox.ini new file mode 100644 index 00000000..99fd941b --- /dev/null +++ b/examples/word-count/tox.ini @@ -0,0 +1,14 @@ +[tox] +envlist = py27, + py35, + py36, + py37, +minversion = 3.4.0 +skip_missing_interpreters = true + +[testenv] +description = Run the unit tests under {basepython} +deps = -rrequirements-dev.txt +usedevelop = True +commands = pip install -e . + pytest tests diff --git a/src/class/methods.rs b/src/class/methods.rs index f3c0af89..f3ec8c2e 100644 --- a/src/class/methods.rs +++ b/src/class/methods.rs @@ -1,12 +1,9 @@ // Copyright (c) 2017-present PyO3 Project and Contributors -use std; -use std::ffi::CString; - use ffi; use libc::c_int; - -static NO_PY_METHODS: &'static [PyMethodDefType] = &[]; +use std; +use std::ffi::CString; /// `PyMethodDefType` represents different types of python callable objects. /// It is used by `#[pymethods]` and `#[pyproto]` annotations. @@ -123,9 +120,10 @@ impl PySetterDef { } #[doc(hidden)] +/// The pymethods macro implements this trait so the methods are added to the object pub trait PyMethodsProtocolImpl { fn py_methods() -> &'static [PyMethodDefType] { - NO_PY_METHODS + &[] } } @@ -134,7 +132,7 @@ impl PyMethodsProtocolImpl for T {} #[doc(hidden)] pub trait PyPropMethodsProtocolImpl { fn py_methods() -> &'static [PyMethodDefType] { - NO_PY_METHODS + &[] } }