Skip to content

Commit eaaf382

Browse files
Add RustPython cfg
1 parent 999560a commit eaaf382

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

pyo3-build-config/src/impl_.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ impl InterpreterConfig {
191191
PythonImplementation::CPython => {}
192192
PythonImplementation::PyPy => out.push("cargo:rustc-cfg=PyPy".to_owned()),
193193
PythonImplementation::GraalPy => out.push("cargo:rustc-cfg=GraalPy".to_owned()),
194+
PythonImplementation::RustPython => out.push("cargo:rustc-cfg=RustPython".to_owned()),
194195
}
195196

196197
// If Py_GIL_DISABLED is set, do not build with limited API support
@@ -780,6 +781,7 @@ pub enum PythonImplementation {
780781
CPython,
781782
PyPy,
782783
GraalPy,
784+
RustPython,
783785
}
784786

785787
impl PythonImplementation {
@@ -813,6 +815,7 @@ impl Display for PythonImplementation {
813815
PythonImplementation::CPython => write!(f, "CPython"),
814816
PythonImplementation::PyPy => write!(f, "PyPy"),
815817
PythonImplementation::GraalPy => write!(f, "GraalVM"),
818+
PythonImplementation::RustPython => write!(f, "RustPython"),
816819
}
817820
}
818821
}
@@ -824,6 +827,7 @@ impl FromStr for PythonImplementation {
824827
"CPython" => Ok(PythonImplementation::CPython),
825828
"PyPy" => Ok(PythonImplementation::PyPy),
826829
"GraalVM" => Ok(PythonImplementation::GraalPy),
830+
"RustPython" => Ok(PythonImplementation::RustPython),
827831
_ => bail!("unknown interpreter: {}", s),
828832
}
829833
}
@@ -1768,6 +1772,7 @@ fn default_lib_name_unix(
17681772
},
17691773

17701774
PythonImplementation::GraalPy => Ok("python-native".to_string()),
1775+
PythonImplementation::RustPython => Ok("rustpython-capi".to_string()),
17711776
}
17721777
}
17731778

pyo3-build-config/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ pub fn print_expected_cfgs() {
261261
println!("cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)");
262262
println!("cargo:rustc-check-cfg=cfg(PyPy)");
263263
println!("cargo:rustc-check-cfg=cfg(GraalPy)");
264+
println!("cargo:rustc-check-cfg=cfg(RustPython)");
264265
println!("cargo:rustc-check-cfg=cfg(py_sys_config, values(\"Py_DEBUG\", \"Py_REF_DEBUG\", \"Py_TRACE_REFS\", \"COUNT_ALLOCS\"))");
265266
println!("cargo:rustc-check-cfg=cfg(pyo3_disable_reference_pool)");
266267
println!("cargo:rustc-check-cfg=cfg(pyo3_leak_on_drop_without_reference_pool)");
@@ -393,6 +394,7 @@ pub mod pyo3_build_script_impl {
393394
PythonImplementation::CPython => "Python",
394395
PythonImplementation::PyPy => "PyPy",
395396
PythonImplementation::GraalPy => "GraalPy",
397+
PythonImplementation::RustPython => "RustPython",
396398
};
397399
let version = &interpreter_config.version;
398400
let message = format!(

pyo3-ffi/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ fn ensure_python_version(interpreter_config: &InterpreterConfig) -> Result<()> {
122122
return Err(error.finish().into());
123123
}
124124
}
125+
PythonImplementation::RustPython => {}
125126
}
126127

127128
if interpreter_config.abi3 {
@@ -140,6 +141,7 @@ fn ensure_python_version(interpreter_config: &InterpreterConfig) -> Result<()> {
140141
PythonImplementation::GraalPy => warn!(
141142
"GraalPy does not support abi3 so the build artifacts will be version-specific."
142143
),
144+
PythonImplementation::RustPython => {}
143145
}
144146
}
145147

0 commit comments

Comments
 (0)