Show More
@@ -0,0 +1,26 b'' | |||||
|
1 | // debug.rs | |||
|
2 | // | |||
|
3 | // Copyright 2020 Raphaël Gomès <rgomes@octobus.net> | |||
|
4 | // | |||
|
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. | |||
|
7 | ||||
|
8 | //! Module to get debug information about Rust extensions. | |||
|
9 | use cpython::{PyDict, PyModule, PyResult, Python}; | |||
|
10 | ||||
|
11 | /// Create the module, with `__package__` given from parent | |||
|
12 | pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { | |||
|
13 | let dotted_name = &format!("{}.debug", package); | |||
|
14 | let m = PyModule::new(py, dotted_name)?; | |||
|
15 | ||||
|
16 | m.add(py, "__package__", package)?; | |||
|
17 | m.add(py, "__doc__", "Rust debugging information")?; | |||
|
18 | ||||
|
19 | m.add(py, "re2_installed", cfg!(feature = "with-re2"))?; | |||
|
20 | ||||
|
21 | let sys = PyModule::import(py, "sys")?; | |||
|
22 | let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?; | |||
|
23 | sys_modules.set_item(py, dotted_name, &m)?; | |||
|
24 | ||||
|
25 | Ok(m) | |||
|
26 | } |
@@ -30,6 +30,7 b' mod conversion;' | |||||
30 | #[macro_use] |
|
30 | #[macro_use] | |
31 | pub mod ref_sharing; |
|
31 | pub mod ref_sharing; | |
32 | pub mod dagops; |
|
32 | pub mod dagops; | |
|
33 | pub mod debug; | |||
33 | pub mod dirstate; |
|
34 | pub mod dirstate; | |
34 | pub mod discovery; |
|
35 | pub mod discovery; | |
35 | pub mod exceptions; |
|
36 | pub mod exceptions; | |
@@ -47,6 +48,7 b' py_module_initializer!(rustext, initrust' | |||||
47 | let dotted_name: String = m.get(py, "__name__")?.extract(py)?; |
|
48 | let dotted_name: String = m.get(py, "__name__")?.extract(py)?; | |
48 | m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?; |
|
49 | m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?; | |
49 | m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?; |
|
50 | m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?; | |
|
51 | m.add(py, "debug", debug::init_module(py, &dotted_name)?)?; | |||
50 | m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?; |
|
52 | m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?; | |
51 | m.add(py, "dirstate", dirstate::init_module(py, &dotted_name)?)?; |
|
53 | m.add(py, "dirstate", dirstate::init_module(py, &dotted_name)?)?; | |
52 | m.add(py, "revlog", revlog::init_module(py, &dotted_name)?)?; |
|
54 | m.add(py, "revlog", revlog::init_module(py, &dotted_name)?)?; |
General Comments 0
You need to be logged in to leave comments.
Login now