Sebastian Pütz
22881a3c2f
Change add_function, ensure static docstrings.
...
Change add_function to take `&PyCFunction` instead of a wrapper
fn and ensure that dostrings of functions are `&'static str`.
2020-09-09 12:37:37 +02:00
Sebastian Pütz
64b06ea9ec
Change add_submodule()
to take &PyModule
.
...
The C-exported wrapper generated through `#[pymodule]` is only
required for the top-level module.
2020-09-05 15:54:57 +02:00
Sebastian Pütz
e65b849ab6
Doc fixes, changelog and rename.
2020-09-05 10:20:22 +02:00
Sebastian Pütz
795c054511
Possible to pass PyModule as first arg.
...
This commit makes it possible to access the module of a function
by passing the `need_module` argument to the pyfn and pyfunction
macros.
2020-09-04 09:01:21 +02:00
Sebastian Pütz
3214249010
Make python function wrapper creation fallible.
...
Wrapping a function can fail if we can't get the module name.
Based on suggestion by @kngwyu
2020-09-03 15:48:32 +02:00
Sebastian Pütz
5bbca1a052
Set the module of #[pyfunction]
s.
...
Previously neither the module nor the name of the module of
pyfunctions were registered. This commit passes the module and
its name when creating a new pyfunction.
PyModule::add_function and PyModule::add_module have been added and are
set to replace `add_wrapped` in a future release. `add_wrapped` is kept
for compatibility reasons during the transition.
Depending on whether a `PyModule` or `Python` is the argument for the
Python function-wrapper, the module will be registered with the function.
2020-09-03 14:49:28 +02:00
David Hewitt
82cb815afa
Use IntoPy<PyObject> for PyModule::add
2020-08-30 16:24:20 +01:00
David Hewitt
1f37dbc1a7
Various fixes to edge cases with GILGuard
2020-08-06 14:32:59 +01:00
kngwyu
40077245ea
Fix PyModule::dict
2020-03-16 15:45:54 +09:00
kngwyu
e63e0cbf5a
Make it enable to take &PyClass as arguments as pyfunctions/methods
2020-03-04 13:37:26 +09:00
kngwyu
a6fed34e23
Fix clippy warnings in build.rs and tests
2020-02-10 14:53:13 +09:00
Ivan Enderlin
8ed2662251
test: Fix a typo in an error message
...
Thank for the awesome project!
2020-01-24 08:44:23 +01:00
David Hewitt
4b18830f1e
Add #[name]
attribute support for #[pyfunction]
2019-12-17 22:14:28 +00:00
Georg Brandl
ab802cd829
Document and test argument parsing annotations for pyfunctions
2019-06-16 22:13:50 +09:00
kngwyu
0f9a3b1194
Expose py_run macro
2019-06-13 18:18:06 +09:00
Martin Larralde
99fdafbb88
Allow setting the module name for a pyclass ( #499 )
...
* Add `MODULE` const value to `PyTypeInfo` trait
* Allow setting module name in `pyclass` macro arguments
* Add `$module` argument to `pyobject_native_type` macro in `pyo3::types`
* Set the right module for builtin types in `pyo3::types`
* Add `module` argument to example `word_count.WordCounter` class
* Add `module` argument of `pyclass` macro to guide
* Reformat code using `rustfmt`
* Add tests and entry in CHANGELOG.md for `module` argument in `pyclass`
* Make `$module` parameter in `pyobject_native_type` optional
* Make `pyobject_native_type` declare module as `Some("builtins")` by default
2019-06-03 12:18:44 +09:00
ijl
2bb0d05a30
Drop support for python2
2019-03-29 12:37:26 +00:00
konstin
97189a16b9
Try fixing cargo fmt on travis ci
2019-03-24 17:19:15 +01:00
Miles Granger
711155d7ad
Update tests & docs with IntoPyDict::into_py_dict(py)
2019-03-20 20:04:00 +01:00
konstin
6cd07c369c
Simpler new and clippy fixes
2019-02-23 18:38:00 +01:00
konstin
ad590bd158
Some api improvements
2019-02-23 18:01:22 +01:00
konstin
9e53418aad
Less feature(specialization)
2019-02-01 18:09:51 +01:00
konstin
c868cc3e4b
Fix test
2019-02-01 16:31:18 +01:00
konstin
0495ee52d3
ffi2 to rust 2018
2019-02-01 15:25:58 +01:00
konstin
936f0153e8
Migrate to rust 2018
2019-02-01 14:23:29 +01:00
konstin
9c8c5a6063
Rename #[pymodinit] to #[pymodule]
2018-11-15 19:43:29 +01:00
konstin
863ffb161f
Add wrap_module macro
2018-11-15 19:43:29 +01:00
konstin
3a95d163ca
New rustfmt version
...
You might need to upgrade to the latest nightly to get the same results
2018-09-28 23:34:57 +02:00
konstin
302c099a76
Big refactoring to shrink the prelude
2018-09-21 23:34:28 +02:00
konstin
4c1ff24b2b
Fix raw identifiers
2018-09-03 20:50:18 +02:00
konstin
991a8b94d2
More nightly fixes
2018-08-19 20:42:17 +02:00
konstin
83db765889
Refactoring
2018-07-30 22:56:25 +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
80096ae143
rudtfmt the tests
...
With some careful refactoring alongside
2018-06-15 21:21:12 +02:00
konstin
f9ff7cd465
Ignore test because of a docmatic bug
...
See https://github.com/assert-rs/docmatic/issues/4
2018-06-15 15:59:22 +02:00
Kevin Phillips
7412eda4b0
Changed the import for the test_module to include ToPyObject in order to make travis CI pass
2018-05-21 16:34:44 +02:00
Kevin Phillips
9544adaf1d
Marked from_code on PyModule to only work with Python 3. It could work with Python 2 if you call, for example, Py_CompileStringFlags and pass std::prt::null_mut() as the last argument and when calling PyImport_ExecCodeModuleEx passing mutable pointers for the first and last arguments. I also added a test for this to test_module.rs
2018-05-21 16:03:21 +02:00
Martin Larralde
31ff8356b6
Add some additional test cases to test_methods
2018-05-14 18:47:13 +02: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
5a8f5034d6
Fix make test
...
This is a follow-up to #147
2018-05-01 20:15:43 +02:00
konstin
2ee1102ef2
Add test for module
2018-04-30 23:32:25 +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
7f68835877
Add unit test for module
2018-04-30 22:38:48 +02:00