rust/hg-pyo3/src/lib.rs
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Jan 2025 14:50:06 +0100
changeset 52592 87ceb51d124c
parent 52531 4c9e31984b3a
child 52774 0f9ed7e7a71b
permissions -rw-r--r--
run-tests: drop jython support I don't think we heard anything about jython support for the past 15 years, so let's drop special support for it in run-tests.py it is most probably broken at that point.

use pyo3::prelude::*;

mod ancestors;
mod convert_cpython;
mod dagops;
mod exceptions;
mod revision;
mod util;

#[pymodule]
fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add(
        "__doc__",
        "Mercurial core concepts - Rust implementation exposed via PyO3",
    )?;
    // the module's __name__ is pyo3_rustext, not mercurial.pyo3_rustext
    // (at least at this point).
    let name: String = m.getattr("__name__")?.extract()?;
    let dotted_name = format!("mercurial.{}", name);

    m.add_submodule(&ancestors::init_module(py, &dotted_name)?)?;
    m.add_submodule(&dagops::init_module(py, &dotted_name)?)?;
    m.add("GraphError", py.get_type::<exceptions::GraphError>())?;
    Ok(())
}