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