Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61ab0e3

Browse files
committed
build.rs checks for CPython
1 parent 42094e3 commit 61ab0e3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ fn main() {
1010
println!("cargo:rerun-if-env-changed=LDFLAGS");
1111
println!("cargo:rerun-if-env-changed=ORJSON_DISABLE_YYJSON");
1212
println!("cargo:rerun-if-env-changed=RUSTFLAGS");
13+
println!("cargo:rustc-check-cfg=cfg(CPython)");
14+
println!("cargo:rustc-check-cfg=cfg(GraalPy)");
1315
println!("cargo:rustc-check-cfg=cfg(intrinsics)");
1416
println!("cargo:rustc-check-cfg=cfg(optimize)");
1517
println!("cargo:rustc-check-cfg=cfg(Py_3_10)");
@@ -20,12 +22,19 @@ fn main() {
2022
println!("cargo:rustc-check-cfg=cfg(Py_3_15)");
2123
println!("cargo:rustc-check-cfg=cfg(Py_3_9)");
2224
println!("cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)");
25+
println!("cargo:rustc-check-cfg=cfg(PyPy)");
2326

2427
let python_config = pyo3_build_config::get();
2528
for cfg in python_config.build_script_outputs() {
2629
println!("{cfg}");
2730
}
2831

32+
if python_config.implementation == pyo3_build_config::PythonImplementation::CPython {
33+
println!("cargo:rustc-cfg=CPython");
34+
} else {
35+
panic!("orjson only supports CPython")
36+
}
37+
2938
#[allow(unused_variables)]
3039
let is_64_bit_python = matches!(python_config.pointer_width, Some(64));
3140

src/str/pyunicode_new.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use pyo3_ffi::{PyASCIIObject, PyCompactUnicodeObject, PyObject};
55

66
macro_rules! validate_str {
77
($ptr:expr) => {
8+
#[cfg(CPython)]
89
debug_assert!(ffi!(_PyUnicode_CheckConsistency($ptr.cast::<PyObject>(), 1)) == 1);
910
};
1011
}

0 commit comments

Comments
 (0)