##// END OF EJS Templates
rust-cpython: remove invalid __package__ attribute...
Yuya Nishihara -
r41166:d43719bd default
parent child Browse files
Show More
@@ -1,42 +1,41 b''
1 // lib.rs
1 // lib.rs
2 //
2 //
3 // Copyright 2018 Georges Racinet <gracinet@anybox.fr>
3 // Copyright 2018 Georges Racinet <gracinet@anybox.fr>
4 //
4 //
5 // This software may be used and distributed according to the terms of the
5 // This software may be used and distributed according to the terms of the
6 // GNU General Public License version 2 or any later version.
6 // GNU General Public License version 2 or any later version.
7
7
8 //! Python bindings of `hg-core` objects using the `cpython` crate.
8 //! Python bindings of `hg-core` objects using the `cpython` crate.
9 //! Once compiled, the resulting single shared library object can be placed in
9 //! Once compiled, the resulting single shared library object can be placed in
10 //! the `mercurial` package directly as `rustext.so` or `rustext.dll`.
10 //! the `mercurial` package directly as `rustext.so` or `rustext.dll`.
11 //! It holds several modules, so that from the point of view of Python,
11 //! It holds several modules, so that from the point of view of Python,
12 //! it behaves as the `cext` package.
12 //! it behaves as the `cext` package.
13 //!
13 //!
14 //! Example:
14 //! Example:
15 //! ```
15 //! ```
16 //! >>> from mercurial.rustext import ancestor
16 //! >>> from mercurial.rustext import ancestor
17 //! >>> ancestor.__doc__
17 //! >>> ancestor.__doc__
18 //! 'Generic DAG ancestor algorithms - Rust implementation'
18 //! 'Generic DAG ancestor algorithms - Rust implementation'
19 //! ```
19 //! ```
20
20
21 #[macro_use]
21 #[macro_use]
22 extern crate cpython;
22 extern crate cpython;
23 extern crate hg;
23 extern crate hg;
24 extern crate libc;
24 extern crate libc;
25
25
26 mod ancestors;
26 mod ancestors;
27 mod cindex;
27 mod cindex;
28 mod exceptions;
28 mod exceptions;
29
29
30 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
30 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
31 m.add(
31 m.add(
32 py,
32 py,
33 "__doc__",
33 "__doc__",
34 "Mercurial core concepts - Rust implementation",
34 "Mercurial core concepts - Rust implementation",
35 )?;
35 )?;
36
36
37 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
37 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
38 m.add(py, "__package__", "mercurial")?;
39 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?;
38 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?;
40 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
39 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
41 Ok(())
40 Ok(())
42 });
41 });
General Comments 0
You need to be logged in to leave comments. Login now