##// END OF EJS Templates
rust-python3: useless python2 specific import...
Georges Racinet -
r42549:5b795108 default
parent child Browse files
Show More
@@ -1,54 +1,53 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 //! ```text
16 //! ```text
17 //! >>> from mercurial.rustext import ancestor
17 //! >>> from mercurial.rustext import ancestor
18 //! >>> ancestor.__doc__
18 //! >>> ancestor.__doc__
19 //! 'Generic DAG ancestor algorithms - Rust implementation'
19 //! 'Generic DAG ancestor algorithms - Rust implementation'
20 //! ```
20 //! ```
21
21
22 #[macro_use]
22 #[macro_use]
23 extern crate cpython;
23 extern crate cpython;
24 extern crate hg;
24 extern crate hg;
25 extern crate libc;
25 extern crate libc;
26 extern crate python27_sys;
27
26
28 pub mod ancestors;
27 pub mod ancestors;
29 mod cindex;
28 mod cindex;
30 mod conversion;
29 mod conversion;
31 pub mod dagops;
30 pub mod dagops;
32 pub mod discovery;
31 pub mod discovery;
33 pub mod exceptions;
32 pub mod exceptions;
34 pub mod dirstate;
33 pub mod dirstate;
35 pub mod filepatterns;
34 pub mod filepatterns;
36
35
37 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
36 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| {
38 m.add(
37 m.add(
39 py,
38 py,
40 "__doc__",
39 "__doc__",
41 "Mercurial core concepts - Rust implementation",
40 "Mercurial core concepts - Rust implementation",
42 )?;
41 )?;
43
42
44 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
43 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
45 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?;
44 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?;
46 m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?;
45 m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?;
47 m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?;
46 m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?;
48 m.add(py, "dirstate", dirstate::init_module(py, &dotted_name)?)?;
47 m.add(py, "dirstate", dirstate::init_module(py, &dotted_name)?)?;
49 m.add(py, "filepatterns", filepatterns::init_module(py, &dotted_name)?)?;
48 m.add(py, "filepatterns", filepatterns::init_module(py, &dotted_name)?)?;
50 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
49 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
51 m.add(py, "PatternFileError", py.get_type::<exceptions::PatternFileError>())?;
50 m.add(py, "PatternFileError", py.get_type::<exceptions::PatternFileError>())?;
52 m.add(py, "PatternError", py.get_type::<exceptions::PatternError>())?;
51 m.add(py, "PatternError", py.get_type::<exceptions::PatternError>())?;
53 Ok(())
52 Ok(())
54 });
53 });
General Comments 0
You need to be logged in to leave comments. Login now