You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Checks if the Python interpreter supports free-threaded mode.
4
+
/// Returns true if Python is free-threaded (GIL disabled), false otherwise.
5
+
pubfnis_free_threaded_python() -> bool{
6
+
// Use sysconfig.get_config_var("Py_GIL_DISABLED") as recommended by Python docs at https://docs.python.org/3/howto/free-threading-python.html#identifying-free-threaded-python
7
+
let output = Command::new("python")
8
+
.args([
9
+
"-c",
10
+
"import sysconfig; print(sysconfig.get_config_var('Py_GIL_DISABLED') or 0)",
11
+
])
12
+
.output();
13
+
14
+
match output {
15
+
Ok(output)if output.status.success() => {
16
+
let stdout = String::from_utf8_lossy(&output.stdout);
17
+
stdout.trim() == "1"
18
+
}
19
+
_ => false,// If Python is not available or command fails, assume not free-threaded
0 commit comments