* #[pymodule] mod some_module { ... } v3
Based on #2367 and #3294
Allows to export classes, native classes, functions and submodules and provide an init function
See test/test_module.rs for an example
Future work:
- update examples, README and guide
- investigate having #[pyclass] and #[pyfunction] directly in the #[pymodule]
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
* tests: group exported imports
* Consolidate pymodule macro code to avoid duplicates
* Makes pymodule_init take Bound<'_, PyModule>
* Renames #[pyo3] to #[pymodule_export]
* Gates #[pymodule] mod behind the experimental-declarative-modules feature
* Properly fails on functions inside of declarative modules
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
Due to checking in error outputs these tests only work reliably on stable and
not on intermediate version between our MSRV (currently 1.48) and the current
stable version.
Hence this simplifies things to run only MSRV-compatible tests for the MSRV
builds, anything else for stable builds except for those tests which require the
nightly feature, i.e. the `Ungil` being distinct from the `Send` trait.
Finally, `not_send3` is disabled when using the nightly feature since while `Rc`
is not send, it also not GIL-bound and hence can be passed into `allow_threads`
as it does not actually spawn a new thread.
* ci: test on emscripten target
This adds CI to build libpython3.11 for wasm32-emscripten and
running tests against it. We need to patch instant to work
around the emscripten_get_now:
https://github.com/sebcrozet/instant/pull/47
We also have to patch emscripten to work aroung the "undefined
symbol gxx_personality_v0" error:
https://github.com/emscripten-core/emscripten/issues/17128
I set up a nox file to download and install emscripten,
download and build cpython, set appropriate environment variables
then run cargo test. The workflow just installs python, rust,
node, and nox and runs the nox session.
I xfailed all the test failures. There are problems with datetime.
iter_dict_nosegv and test_filenotfounderror should probably be
fixable. The tests that involve threads or asyncio probably can't
be fixed.
* Some cleanup
* Remove instant patch
* Add explanations for xfails
`pyo3-macros-backend` is now compiled with PyO3 cfgs to enable different magic method definitions based on version.
Add check for correct number of arguments on magic methods.