konstin
fe8a719ee1
Rustfmt all the things ✔️
2018-07-30 23:05:10 +02:00
konstin
ff70f45071
(Hopefully) get travis to build the guide for tags
2018-07-18 23:28:14 +02:00
konstin
3adcac6e61
Replace concat_idents with mashup
2018-07-18 23:17:05 +02:00
konstin
d59bebcc38
Upgrade from proc_macro to use_extern_macros
2018-07-18 13:08:05 +02:00
konstin
fe931a594f
#[pymodinit] now uses the function name as default module name
2018-07-10 00:13:02 +02:00
konstin
4013d40897
Add py
prefix to the proc macros and move them into the root module
...
This is important because `proc_macro_path_invoc` isn't going to be stabilized soon.
2018-07-08 23:33:48 +02:00
konstin
68c14a5707
Merge branch 'master' of https://github.com/PyO3/pyo3
2018-07-03 21:55:43 +02:00
konstin
43eb5fa490
Rename prepare_pyo3_library to init_once
2018-07-03 21:12:57 +02:00
konstin
6645708e4f
Get rid of #[py*] methods
2018-07-03 20:42:02 +02:00
kngwyu
70e1879d59
Make python pub
2018-07-02 00:06:01 +09:00
konstin
858a124374
Merge master
2018-05-05 15:50:04 +02:00
konstin
15204bab56
Better way to add functions to modules
2018-05-02 19:26:54 +02:00
konstin
0880ac166c
Merge master
2018-05-01 20:41:35 +02:00
konstin
d0c42dfcc1
Fix compilation on nightly
2018-05-01 15:44:38 +02:00
konstin
6113428746
Allow defining functions outside of the module declarations
...
This commit consists of
* a proc macro to convert rust functions into python functions (`#[function]`),
* a macro to register a function in a module (`add_function_to_module!`)
* Documenting both the old and the new way in the book
2018-04-30 23:17:09 +02:00
konstin
45bb09b3e8
Relax return type requirements
...
Allows returning essentially arbitrary types by wrapping them into a PyResult. This is done with a conversion trait that specializes for PyResult.
2018-04-06 17:22:09 +02:00
Nikolay Kim
b7a8d25338
const fns that we use are stable now
2018-02-21 09:23:58 -08:00
Nikolay Kim
b738c1a04b
clippy warnings
2018-01-19 10:02:36 -08:00
Nikolay Kim
324a6b2697
drop RefFromPyObject; allow mut refs #106
2018-01-19 09:04:42 -08:00
dkao1978
eb9050ab90
Add documentation for compiling on MacOS ( #89 )
...
* Update README.md
* Update overview.md
* Update lib.rs
* Update README.md
* Add links
2017-10-22 11:17:35 +08:00
messense
703883687a
Add features to tests
2017-09-19 20:03:03 +08:00
messense
9da1247484
Fix build on rustc nightly-2017-09-16
...
Use forked version of spin-rs for now.
Closes #79
2017-09-19 19:51:25 +08:00
Nikolay Kim
ed8599cfd3
refactor __new__ method implementation
2017-08-08 00:27:33 -07:00
Nikolay Kim
130c33ec09
export IntoPyDictPointer
2017-08-03 15:55:23 -07:00
Nikolay Kim
cd6558a19b
Introduce IntoPyDictPointer similar to IntoPyTuple #69
2017-08-03 15:01:52 -07:00
Nikolay Kim
c44e23f4b9
add prelude mod
2017-07-31 10:42:55 -07:00
Nikolay Kim
325070f6c9
refactor downcast process
2017-07-28 23:19:00 -07:00
Nikolay Kim
a4fd878cb7
pyerr cleanups
2017-07-26 14:28:04 -07:00
Nikolay Kim
e45eb6e878
rename ToPyErr to PyErrArguments
2017-07-26 10:47:17 -07:00
Nikolay Kim
a120bbf15e
Refactor implementation. Drop parameter from constructor
2017-07-26 01:11:00 -07:00
Nikolay Kim
2ee6419464
do not catch rust panics
2017-07-20 14:21:57 -07:00
Nikolay Kim
fc1df289bd
drop PyClone trait; doc cleanups
2017-07-18 10:13:50 -07:00
Nikolay Kim
4daac50781
remove associated_consts feature
2017-07-14 03:17:57 -07:00
Nikolay Kim
8eb5dc0667
use associated consts
2017-07-13 16:45:50 -07:00
Nikolay Kim
ed31492d36
rename pointer mod to object
2017-07-13 13:05:50 -07:00
Nikolay Kim
c1c4648add
delay decref until gil available
2017-07-09 12:08:57 +06:00
Nikolay Kim
503e4221cc
support &str as fn param
2017-06-24 15:28:53 -07:00
messense
4e836cb229
Don't reexport Py_hash_t and Py_ssize_t
2017-06-24 22:36:45 +08:00
messense
378fae9659
Hide argparse module in API docs
2017-06-24 22:30:46 +08:00
messense
a5e3429d60
Remove unnecessary ObjectProtocol
import
2017-06-24 22:29:35 +08:00
messense
0ba541e762
Add missing module level docs
2017-06-24 16:47:36 +08:00
Nikolay Kim
cc56ded6bf
fix python2 extension module initialization
2017-06-23 11:51:15 -07:00
Nikolay Kim
61f85c730e
fix doc tests; fix unsued import warning
2017-06-23 10:38:04 -07:00
Nikolay Kim
a58aa7b5e6
rename PyObject
2017-06-22 20:56:09 -07:00
Nikolay Kim
cb969161c6
fix unchecked downcast; added objects pool
2017-06-22 10:26:07 -07:00
Nikolay Kim
b9377849c8
rename modules
2017-06-22 01:16:22 -07:00
Nikolay Kim
c48386affa
stopping point
2017-06-22 01:04:37 -07:00
Nikolay Kim
7cf8e1ab80
modify PyDict
2017-06-21 14:08:16 -07:00
Nikolay Kim
96788bf192
more types
2017-06-21 13:10:40 -07:00
Nikolay Kim
08ddb3f14f
other types
2017-06-21 12:33:21 -07:00
Nikolay Kim
c4ba2b0f2e
rename InstancePtr to AsPyRef
2017-06-20 14:22:49 -07:00
Nikolay Kim
40efa5c955
rename Ptr to Py
2017-06-19 23:57:34 -07:00
Nikolay Kim
7b5521fdb3
simplify instance ptr, droped #[py::ptr] annotation attr
2017-06-19 20:55:07 -07:00
Nikolay Kim
b4deb673c7
refactor #[args()] attribute #40
2017-06-19 14:05:14 -07:00
Nikolay Kim
005c36548b
add specialization to docs
2017-06-18 09:28:21 -07:00
messense
75d6684d25
Clarify Python module doc string
2017-06-18 23:15:10 +08:00
Nikolay Kim
60a965edc3
update link to example py extension
2017-06-15 14:30:11 -07:00
Nikolay Kim
e85db971f9
fix module export functions
2017-06-15 14:20:30 -07:00
Nikolay Kim
0679fec859
update docs
2017-06-15 11:13:58 -07:00
Nikolay Kim
ac0594a5b2
do not use pub pointers mod
2017-06-15 10:36:41 -07:00
Nikolay Kim
3bed79fe0b
add clippy and doc to travis
2017-06-15 09:11:19 -07:00
Nikolay Kim
5bf6ce3864
added __unicode__ method to PyObjectProtocol
2017-06-15 07:48:57 -07:00
Nikolay Kim
bd7a0feb8c
merge master
2017-06-15 07:16:40 -07:00
messense
b8b9daf67a
Enable doc test for src/lib.rs examples
2017-06-15 16:06:04 +08:00
Nikolay Kim
d9bd485072
macro_use is not requires
2017-06-14 14:42:05 -07:00
Nikolay Kim
293569b6af
remove import
2017-06-14 14:23:51 -07:00
Nikolay Kim
706477f139
replace py_fn! macro with pyfn attribute
2017-06-14 14:08:30 -07:00
Nikolay Kim
6204a06cbc
update docstring
2017-06-11 23:54:24 -07:00
Nikolay Kim
fdd9ac7ae9
various improvements
2017-06-11 18:30:56 -07:00
Nikolay Kim
805429e0f4
remove unneeded macro
2017-06-11 16:49:25 -07:00
Nikolay Kim
05d4a0a9a4
rename ffi to ffi3
2017-06-11 16:47:27 -07:00
Nikolay Kim
3b4d147219
initial impl for py2
2017-06-11 16:35:24 -07:00
messense
cb68cd23a2
Fix some clippy warnings ( #26 )
2017-06-11 23:46:23 +08:00
Nikolay Kim
c28a619efd
add free list support
2017-06-09 14:27:37 -07:00
messense
e12e98a7c1
Convert some std error types to PyErr ( #22 )
...
* Convert some std error types to PyErr
* Add ToPyErr trait
2017-06-08 09:40:30 +08:00
Nikolay Kim
a584ce12e5
release py objects aftre use
2017-06-06 19:26:59 -07:00
Nikolay Kim
84f5578997
varios cleanups
2017-06-05 20:25:00 -07:00
Nikolay Kim
a448aa54cc
clone_ref return Self
2017-06-03 17:42:12 -07:00
Nikolay Kim
57cc139c81
drop Py pointer
2017-06-03 17:27:26 -07:00
Nikolay Kim
b75160daf3
remove pyobject lifetime
2017-06-02 18:58:16 -07:00
Nikolay Kim
27bd365f5c
cleanups
2017-06-02 09:23:48 -07:00
Nikolay Kim
cbfdfa2d07
better naming
2017-06-01 15:06:48 -07:00
Nikolay Kim
fc762288fe
use From instead of as_object; fix type object
2017-06-01 13:34:46 -07:00
Nikolay Kim
9176dc4df1
consistent naming for pointers
2017-06-01 10:35:02 -07:00
Nikolay Kim
6834a18a5b
add ptr support to class
2017-05-31 20:50:40 -07:00
Nikolay Kim
2f3ea202b3
add mirror ptr types for native py classes
2017-05-31 15:52:13 -07:00
Nikolay Kim
92bf7b9c05
rename pptr to PyObjectPtr
2017-05-31 01:08:39 -07:00
Nikolay Kim
5d25c7deea
simplify Py and PyPtr objects
2017-05-30 18:57:36 -07:00
Nikolay Kim
3040ac12b9
refactor ToPyObject
2017-05-30 17:23:23 -07:00
Nikolay Kim
b8913a3705
refactor IntoPyObject trait; rename pptr into pyptr, introduce pptr pointers
2017-05-30 16:29:13 -07:00
Nikolay Kim
61b8bd0695
fix ptr borrowing PyTuple::get_item
2017-05-29 18:36:44 -07:00
Nikolay Kim
51ac8c9c78
better gil token scope
2017-05-29 13:30:38 -07:00
Nikolay Kim
ea8ccf190a
special treatment for native python objects
2017-05-29 02:47:27 -07:00
Nikolay Kim
55d0d58734
added pptr pointer
2017-05-28 21:19:29 -07:00
Nikolay Kim
969cba2c16
remove Token
2017-05-28 08:57:34 -07:00
Nikolay Kim
6c87c9b77b
introduce python token system
2017-05-27 22:45:48 -07:00
Nikolay Kim
6205be98b8
introduce PythonToken; cleanup number protocol
2017-05-27 10:49:38 -07:00
Nikolay Kim
d165dbe4d4
fixed gil lifetime; pass py object into protocol methods
2017-05-26 14:43:28 -07:00
Nikolay Kim
0979653b98
various cleanups
2017-05-25 08:06:10 -07:00
Nikolay Kim
f3176dacfc
use pyptr for everything
2017-05-25 08:06:06 -07:00
Nikolay Kim
d6fb90bdc2
stopping point
2017-05-25 07:58:25 -07:00
Nikolay Kim
56d93249ab
pyptr
2017-05-25 07:58:25 -07:00
Nikolay Kim
1f2c927bd5
update buffer proto tests
2017-05-19 23:18:54 -07:00
Nikolay Kim
0c7293125c
simplify class generation
2017-05-18 23:29:09 -07:00
Nikolay Kim
8b3c280450
fix optional arg generation
2017-05-18 11:15:06 -07:00
Nikolay Kim
04168ab86e
added fn spec for args parsing
2017-05-18 00:05:49 -07:00
Nikolay Kim
c9aefd7e5f
drop py_class
2017-05-16 23:43:39 -07:00
Nikolay Kim
34e4d956f1
basic object customization interface
2017-05-16 16:54:27 -07:00
Nikolay Kim
521a91fbc2
remove unused imports
2017-05-16 14:18:31 -07:00
Nikolay Kim
5427a33c75
stopping point
2017-05-15 22:24:06 -07:00
Nikolay Kim
f4feade487
add PyAsyncProtocol
2017-05-14 18:55:04 -07:00
Nikolay Kim
088d44f8d1
simplify ToPyObject trait
2017-05-14 14:42:56 -07:00
Nikolay Kim
3e20979f3f
implement buffer protocol with proc macro
2017-05-14 12:52:30 -07:00
Nikolay Kim
03a3817878
update readme and travis
2017-05-12 23:01:54 -07:00
Nikolay Kim
a95de027c1
update tests
2017-05-12 22:43:17 -07:00
Nikolay Kim
8a295793a0
include py3 ffi info into crate
2017-05-12 22:05:00 -07:00
Luthaf
d615c319f6
Implement optional parameters for reference types
2017-01-26 21:35:16 +01:00
Daniel Grunwald
3152ef22f0
Expand on the buffer protocol.
...
When compiling with --feature nightly, we now use specialization to optimize extract::<Vec<PrimititeType>>() from an object implementing the buffer protocol.
2017-01-20 23:14:29 +01:00
Daniel Grunwald
af8131f858
Initial attempt at the buffer protocol.
...
Does not yet provide a safe way of accessing the buffer contents.
2017-01-20 01:08:51 +01:00
Daniel Grunwald
e2d7781433
Add "extension-module" feature to suppress linking pythonX.Y.so.
...
The symbols are instead kept unresolved, so that they can be used with
any compatible python interpreter, even if the target system uses a
statically linked python and lacks pythonX.Y.so altogether.
2016-12-17 21:17:11 +01:00
Daniel Grunwald
4cb29c14fa
Remove hacks for compatibility with old rust versions. The new minimum required version is Rust 1.13.0.
...
This significantly reduces our #[cfg(feature="nightly")] usage.
2016-12-17 16:05:21 +01:00
Daniel Grunwald
f6ed2bbae9
Fix #10 : Windows support.
...
We keep the #[link] attributes in #[cfg_attr(windows)] so that we don't require a nightly Rust build on non-Windows platforms.
This can be simplified once RFC 1717 is available in a stable rust version.
This commit also increases the minimum Rust version to 1.13.
2016-12-17 15:46:52 +01:00
Daniel Grunwald
278c1aece8
Fix #56 : PyModuleDef changed "m_slots" to "m_reload" in Python 3.5.
2016-12-10 13:03:51 +01:00
Samuel Cormier-Iijima
d2b9533406
Use uppercase names for static variables to fix warnings
2016-11-11 21:50:18 -05:00
Daniel Grunwald
1129131501
Remove #[feature(unsafe_no_drop_flag)]: it's no longer necessary with the latest nightlies.
...
Warning: to use rust-cpython with --feature nightly, you now must use 'rustc 1.13.0-nightly (e9bc1bac8 2016-08-24)' or newer; or you'll get segfaults due to the drop flags.
Use of rust-cpython with stable rust is not affected.
2016-08-25 21:22:18 +02:00
Samuel Cormier-Iijima
305bc4324d
Add support for overloading comparison operators with __richcompare__
2016-06-06 16:08:48 -04:00
Daniel Grunwald
0222176836
#40 : split ExtractPyObject into two traits:
...
* FromPyObject for all conversions that don't need to borrow temporaries
* RefFromPyObject for extracting references out of temporaries
(currently only used for extracting `&str`)
2016-05-08 21:25:09 +02:00
Daniel Grunwald
be0c1573aa
py_class!: add support for __str__, __repr__, __unicode__ and __format__
2016-05-05 07:31:14 +02:00
Daniel Grunwald
9aec3f33f1
We only need num-traits, not the full num crate.
2016-04-17 23:35:17 +02:00
Daniel Grunwald
fffcf57834
Add support for __len__ special method.
2016-04-17 23:26:33 +02:00
Daniel Grunwald
a14e3d2b77
Share macro code between tp_new and other class methods.
2016-04-17 18:04:58 +02:00
Daniel Grunwald
2e977a9c21
gc integration: __traverse__ method
2016-04-14 18:41:29 +02:00
Daniel Grunwald
271a44475d
panic::recover -> panic::catch_unwind
2016-04-14 18:41:29 +02:00
Daniel Grunwald
337a90c2fb
Reserve special method names
...
Some of these might work via the normal "instance method" functionality,
but we'll need testcases to be sure.
2016-03-12 19:08:51 +01:00
Daniel Grunwald
cc81a01077
py_class!: add support for instance methods
2016-03-12 17:58:50 +01:00
Daniel Grunwald
ab83b4f4a1
#14 ; Convert Rust panic to Python SystemError
2016-03-12 01:31:06 +01:00
Daniel Grunwald
309182cfe8
py_class!: Add support for "def __new__(cls)".
2016-03-12 00:06:39 +01:00
Daniel Grunwald
547879ef0f
Remove rustobject (PyRustObject, TypeBuilder).
...
Add new py_class!() macro that generates a static type.
2016-03-09 01:07:50 +01:00
Daniel Grunwald
3af6e17841
WIP: big macro refactoring
...
* Introduce py_argparse_parse_plist!() to allow a more flexible
param list syntax.
* py_fn!() syntax changed
* Remove py_method!() / py_class_method!() macros.
These are of limited use when building dynamic types,
and not useful for py_class!() static types.
2016-03-07 23:22:44 +01:00
Daniel Grunwald
be682d848f
WIP: generalize py_argparse!() macro
2016-03-06 13:33:57 +01:00
Daniel Grunwald
acc5712536
Don't flatten the rustobject module + started implementing the py_class!() macro.
2016-03-06 06:29:43 +01:00
Daniel Grunwald
d705620502
Add support for Rust stable.
...
All functions that depend on PyObject having the same memory layout
as *mut ffi::PyObject should now be hidden behind #[cfg(feature="nightly")].
2016-03-06 01:08:40 +01:00
Daniel Grunwald
ad7f43efc7
Remove #![feature(optin_builtin_traits)] usage
2016-03-06 00:22:16 +01:00
Daniel Grunwald
7c90651157
Make use of nightly const_fn + shared features optional.
2016-03-06 00:03:17 +01:00
Daniel Grunwald
53353d374b
Remove dependency on interpolate_idents.
...
We now use the generic <DUMMY> hack to avoid duplicate extern "C" symbols.
See rust-lang/rust#26201 .
py_module_initializer!() calls now need to manually concatenate the module
name with the prefixes "init" and "PyInit_".
2016-03-05 23:20:53 +01:00
Daniel Grunwald
a4f946096c
Add back accidentally removed #[macro_use]
2016-03-05 17:44:30 +01:00
Daniel Grunwald
067f262876
Some documentation updates
2016-03-05 17:41:04 +01:00
Daniel Grunwald
d22fbb31ce
Refactor py_fn / py_method / py_class_method macros
2016-03-05 15:05:41 +01:00
Daniel Grunwald
c01a1e8306
Use std::ptr::Shared in PyObject to enable the null pointer optimization.
2016-03-05 02:01:03 +01:00
Daniel Grunwald
b617af7c5b
Add PyTypeBuilder::set_new().
2016-03-05 01:16:54 +01:00