1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::pyobject::PyObjectRef;
use crate::version;
use crate::vm::VirtualMachine;

pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
    let ctx = &vm.ctx;
    py_module!(vm, "platform", {
        "python_branch" => ctx.new_function(platform_python_branch),
        "python_build" => ctx.new_function(platform_python_build),
        "python_compiler" => ctx.new_function(platform_python_compiler),
        "python_implementation" => ctx.new_function(platform_python_implementation),
        "python_revision" => ctx.new_function(platform_python_revision),
        "python_version" => ctx.new_function(platform_python_version),
    })
}

fn platform_python_implementation(_vm: &VirtualMachine) -> String {
    "RustPython".to_owned()
}

fn platform_python_version(_vm: &VirtualMachine) -> String {
    version::get_version_number()
}

fn platform_python_compiler(_vm: &VirtualMachine) -> String {
    version::get_compiler()
}

fn platform_python_build(_vm: &VirtualMachine) -> (String, String) {
    (version::get_git_identifier(), version::get_git_datetime())
}

fn platform_python_branch(_vm: &VirtualMachine) -> String {
    version::get_git_branch()
}

fn platform_python_revision(_vm: &VirtualMachine) -> String {
    version::get_git_revision()
}