fn parse_sysconfigdata()

in include/pyo3/pyo3-build-config/src/impl_.rs [2871:2921]


    fn parse_sysconfigdata() {
        // A best effort attempt to get test coverage for the sysconfigdata parsing.
        // Might not complete successfully depending on host installation; that's ok as long as
        // CI demonstrates this path is covered!

        let interpreter_config = crate::get();

        let lib_dir = match &interpreter_config.lib_dir {
            Some(lib_dir) => Path::new(lib_dir),
            // Don't know where to search for sysconfigdata; never mind.
            None => return,
        };

        let cross = CrossCompileConfig {
            lib_dir: Some(lib_dir.into()),
            version: Some(interpreter_config.version),
            implementation: Some(interpreter_config.implementation),
            target: triple!("x86_64-unknown-linux-gnu"),
            abiflags: if interpreter_config.is_free_threaded() {
                Some("t".into())
            } else {
                None
            },
        };

        let sysconfigdata_path = match find_sysconfigdata(&cross) {
            Ok(Some(path)) => path,
            // Couldn't find a matching sysconfigdata; never mind!
            _ => return,
        };
        let sysconfigdata = super::parse_sysconfigdata(sysconfigdata_path).unwrap();
        let parsed_config = InterpreterConfig::from_sysconfigdata(&sysconfigdata).unwrap();

        assert_eq!(
            parsed_config,
            InterpreterConfig {
                abi3: false,
                build_flags: BuildFlags(interpreter_config.build_flags.0.clone()),
                pointer_width: Some(64),
                executable: None,
                implementation: PythonImplementation::CPython,
                lib_dir: interpreter_config.lib_dir.to_owned(),
                lib_name: interpreter_config.lib_name.to_owned(),
                shared: true,
                version: interpreter_config.version,
                suppress_build_script_link_lines: false,
                extra_build_script_lines: vec![],
                python_framework_prefix: None,
            }
        )
    }