Hello Python
This commit is contained in:
parent
e2260a534f
commit
d63bebe601
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("cargo:rustc-link-search=./");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
|
||||
int hello_python()
|
||||
{
|
||||
Py_Initialize();
|
||||
PyRun_SimpleString("from time import time,ctime\n"
|
||||
"print('Today is', ctime(time()), 'from cpython')\n");
|
||||
if (Py_FinalizeEx() < 0) {
|
||||
printf("Failure during FinalizeEx");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -5,6 +5,7 @@ mod errors;
|
|||
mod exercises;
|
||||
mod jour1;
|
||||
mod jour2;
|
||||
mod python;
|
||||
mod rpg;
|
||||
mod starwars;
|
||||
mod tests;
|
||||
|
@ -19,4 +20,5 @@ fn main() {
|
|||
doc::main();
|
||||
errors::main();
|
||||
concurrency::main();
|
||||
python::main();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
pub fn main() {
|
||||
#[link(name = "hello_python")]
|
||||
extern "C" {
|
||||
fn hello_python();
|
||||
}
|
||||
unsafe {
|
||||
hello_python();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue