Merge pull request #564 from kngwyu/paste

Replace mashup with paste
This commit is contained in:
Yuji Kanagawa 2019-08-11 18:42:21 +09:00 committed by GitHub
commit 1f85593d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 27 deletions

View File

@ -21,7 +21,7 @@ matrix:
- name: Minimum nightly - name: Minimum nightly
python: "3.7" python: "3.7"
# Keep this synced up with build.rs # Keep this synced up with build.rs
env: TRAVIS_RUST_VERSION=nightly-2019-06-22 env: TRAVIS_RUST_VERSION=nightly-2019-07-19
# Tested via anaconda PyPy (since travis's PyPy version is too old) # Tested via anaconda PyPy (since travis's PyPy version is too old)
- name: PyPy3.5 7.0 - name: PyPy3.5 7.0
python: "3.7" python: "3.7"

View File

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Implementing the Using the `gc` parameter for `pyclass` (e.g. `#[pyclass(gc)]`) without implementing the `class::PyGCProtocol` trait is now a compile-time error. Failing to implement this trait could lead to segfaults. [#532](https://github.com/PyO3/pyo3/pull/532) * Implementing the Using the `gc` parameter for `pyclass` (e.g. `#[pyclass(gc)]`) without implementing the `class::PyGCProtocol` trait is now a compile-time error. Failing to implement this trait could lead to segfaults. [#532](https://github.com/PyO3/pyo3/pull/532)
* `PyByteArray::data` has been replaced with `PyDataArray::to_vec` because returning a `&[u8]` is unsound. (See [this comment](https://github.com/PyO3/pyo3/issues/373#issuecomment-512332696) for a great write-up for why that was unsound) * `PyByteArray::data` has been replaced with `PyDataArray::to_vec` because returning a `&[u8]` is unsound. (See [this comment](https://github.com/PyO3/pyo3/issues/373#issuecomment-512332696) for a great write-up for why that was unsound)
* Replace `mashup` with `paste`.
## [0.7.0] - 2018-05-26 ## [0.7.0] - 2018-05-26

View File

@ -23,11 +23,11 @@ libc = "0.2.54"
spin = "0.5.0" spin = "0.5.0"
num-traits = "0.2.6" num-traits = "0.2.6"
pyo3cls = { path = "pyo3cls", version = "=0.7.0" } pyo3cls = { path = "pyo3cls", version = "=0.7.0" }
mashup = "0.1.9"
num-complex = { version = "0.2.1", optional = true } num-complex = { version = "0.2.1", optional = true }
inventory = "0.1.3" inventory = "0.1.3"
indoc = "0.3.3" indoc = "0.3.3"
unindent = "0.1.3" unindent = "0.1.3"
paste = "0.1.5"
[dev-dependencies] [dev-dependencies]
assert_approx_eq = "1.1.0" assert_approx_eq = "1.1.0"

View File

@ -16,7 +16,7 @@ A comparison with rust-cpython can be found [in the guide](https://pyo3.rs/maste
## Usage ## Usage
PyO3 supports Python 3.5 and up. The minimum required Rust version is 1.34.0-nightly 2019-02-06. PyO3 supports Python 3.5 and up. The minimum required Rust version is 1.37.0-nightly 2019-07-19.
PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0. PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the guide for installation instruction against PyPy. Please refer to the guide for installation instruction against PyPy.

View File

@ -16,7 +16,7 @@ use version_check::{Channel, Date, Version};
/// Specifies the minimum nightly version needed to compile pyo3. /// Specifies the minimum nightly version needed to compile pyo3.
/// Keep this synced up with the travis ci config, /// Keep this synced up with the travis ci config,
/// But note that this is the rustc version which can be lower than the nightly version /// But note that this is the rustc version which can be lower than the nightly version
const MIN_DATE: &'static str = "2019-06-21"; const MIN_DATE: &'static str = "2019-07-18";
const MIN_VERSION: &'static str = "1.37.0-nightly"; const MIN_VERSION: &'static str = "1.37.0-nightly";
/// Information returned from python interpreter /// Information returned from python interpreter

View File

@ -51,4 +51,4 @@ if [ ! -f "$HOME/.cargo/bin/kcov" ]; then
make make
install src/kcov $HOME/.cargo/bin/kcov install src/kcov $HOME/.cargo/bin/kcov
cd $TRAVIS_BUILD_DIR cd $TRAVIS_BUILD_DIR
fi fi

View File

@ -10,7 +10,7 @@ A comparison with rust-cpython can be found [in the guide](https://pyo3.rs/maste
## Usage ## Usage
PyO3 supports Python 3.5 and up. The minimum required Rust version is 1.34.0-nightly 2019-02-06. PyO3 supports Python 3.5 and up. The minimum required Rust version is 1.37.0-nightly 2019-07-19.
PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0. PyPy is also supported (via cpyext) for Python 3.5 only, targeted PyPy version is 7.0.0.
Please refer to the guide for installation instruction against PyPy. Please refer to the guide for installation instruction against PyPy.

26
src/lib.rs Normal file → Executable file
View File

@ -132,7 +132,7 @@ pub use crate::type_object::{PyObjectAlloc, PyRawObject, PyTypeInfo};
// Re-exported for wrap_function // Re-exported for wrap_function
#[doc(hidden)] #[doc(hidden)]
pub use mashup; pub use paste;
// Re-exported for py_run // Re-exported for py_run
#[doc(hidden)] #[doc(hidden)]
pub use indoc; pub use indoc;
@ -183,18 +183,8 @@ pub mod proc_macro {
/// Use this together with `#[pyfunction]` and [types::PyModule::add_wrapped]. /// Use this together with `#[pyfunction]` and [types::PyModule::add_wrapped].
#[macro_export] #[macro_export]
macro_rules! wrap_pyfunction { macro_rules! wrap_pyfunction {
($function_name:ident) => {{ ($function_name: ident) => {{
// Get the mashup macro and its helpers into scope &pyo3::paste::expr! { [<__pyo3_get_function_ $function_name>] }
use pyo3::mashup::*;
mashup! {
// Make sure this ident matches the one in function_wrapper_ident
m["method"] = __pyo3_get_function_ $function_name;
}
m! {
&"method"
}
}}; }};
} }
@ -204,14 +194,8 @@ macro_rules! wrap_pyfunction {
#[macro_export] #[macro_export]
macro_rules! wrap_pymodule { macro_rules! wrap_pymodule {
($module_name:ident) => {{ ($module_name:ident) => {{
use pyo3::mashup::*; pyo3::paste::expr! {
&|py| unsafe { pyo3::PyObject::from_owned_ptr(py, [<PyInit_ $module_name>]()) }
mashup! {
m["method"] = PyInit_ $module_name;
}
m! {
&|py| unsafe { pyo3::PyObject::from_owned_ptr(py, "method"()) }
} }
}}; }};
} }

View File

@ -3,3 +3,5 @@ error: #[pyclass] cannot have generic parameters
| |
4 | struct ClassWithGenerics<A> { 4 | struct ClassWithGenerics<A> {
| ^^^ | ^^^
error: Could not compile `pyo3-tests`.

View File

@ -3,3 +3,5 @@ error: Getter function can only have one argument of type pyo3::Python!
| |
11 | fn get_num(&self, index: u32) {} 11 | fn get_num(&self, index: u32) {}
| ^^^ | ^^^
error: Could not compile `pyo3-tests`.