Mercurial > hg
view rust/hg-cpython/src/lib.rs @ 41130:d43719bd01f0
rust-cpython: remove invalid __package__ attribute
Since mercurial.rustext is a package, its __package__ should be, if set,
"mercurial.rustext". AFAIK, we don't have to set this attribute manually
as the rustext module will be imported by the system importer.
https://stackoverflow.com/a/21233334/10435339
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 06 Jan 2019 11:29:44 +0900 |
parents | 4c25038c112c |
children | dcf818267bc1 |
line wrap: on
line source
// lib.rs // // Copyright 2018 Georges Racinet <gracinet@anybox.fr> // // This software may be used and distributed according to the terms of the // GNU General Public License version 2 or any later version. //! Python bindings of `hg-core` objects using the `cpython` crate. //! Once compiled, the resulting single shared library object can be placed in //! the `mercurial` package directly as `rustext.so` or `rustext.dll`. //! It holds several modules, so that from the point of view of Python, //! it behaves as the `cext` package. //! //! Example: //! ``` //! >>> from mercurial.rustext import ancestor //! >>> ancestor.__doc__ //! 'Generic DAG ancestor algorithms - Rust implementation' //! ``` #[macro_use] extern crate cpython; extern crate hg; extern crate libc; mod ancestors; mod cindex; mod exceptions; py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| { m.add( py, "__doc__", "Mercurial core concepts - Rust implementation", )?; let dotted_name: String = m.get(py, "__name__")?.extract(py)?; m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?; m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?; Ok(()) });