Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix sysconfigdata
  • Loading branch information
youknowone committed Dec 23, 2025
commit a84452ab457c71880e1a90cc488c314596d7d184
1 change: 0 additions & 1 deletion Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def test_main(self):
_main()
self.assertTrue(len(output.getvalue().split('\n')) > 0)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skipIf(sys.platform == "win32", "Does not apply to Windows")
def test_ldshared_value(self):
ldflags = sysconfig.get_config_var('LDFLAGS')
Expand Down
17 changes: 17 additions & 0 deletions crates/vm/src/stdlib/sysconfigdata.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// spell-checker: words LDSHARED ARFLAGS CPPFLAGS CCSHARED BASECFLAGS BLDSHARED

pub(crate) use _sysconfigdata::make_module;

#[pymodule]
Expand All @@ -18,6 +20,21 @@ pub(crate) mod _sysconfigdata {
"MULTIARCH" => MULTIARCH,
// enough for tests to stop expecting urandom() to fail after restricting file resources
"HAVE_GETRANDOM" => 1,
// Compiler configuration for native extension builds
"CC" => "cc",
"CXX" => "c++",
"CFLAGS" => "",
"CPPFLAGS" => "",
"LDFLAGS" => "",
"LDSHARED" => "cc -shared",
"CCSHARED" => "",
"SHLIB_SUFFIX" => ".so",
"SO" => ".so",
"AR" => "ar",
"ARFLAGS" => "rcs",
"OPT" => "",
"BASECFLAGS" => "",
"BLDSHARED" => "cc -shared",
Comment on lines +23 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Platform-specific hardcoded values will be incorrect on Windows.

The hardcoded values for SHLIB_SUFFIX, SO, LDSHARED, and BLDSHARED assume a Unix/Linux environment. On Windows, shared libraries use .dll instead of .so, and the linker commands differ significantly.

🔎 Consider using conditional compilation for platform-specific values
             // Compiler configuration for native extension builds
             "CC" => "cc",
             "CXX" => "c++",
             "CFLAGS" => "",
             "CPPFLAGS" => "",
             "LDFLAGS" => "",
-            "LDSHARED" => "cc -shared",
+            "LDSHARED" => if cfg!(windows) { "link.exe" } else { "cc -shared" },
             "CCSHARED" => "",
-            "SHLIB_SUFFIX" => ".so",
-            "SO" => ".so",
+            "SHLIB_SUFFIX" => if cfg!(windows) { ".dll" } else if cfg!(target_os = "macos") { ".dylib" } else { ".so" },
+            "SO" => if cfg!(windows) { ".pyd" } else { ".so" },
             "AR" => "ar",
             "ARFLAGS" => "rcs",
             "OPT" => "",
             "BASECFLAGS" => "",
-            "BLDSHARED" => "cc -shared",
+            "BLDSHARED" => if cfg!(windows) { "link.exe" } else { "cc -shared" },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Compiler configuration for native extension builds
"CC" => "cc",
"CXX" => "c++",
"CFLAGS" => "",
"CPPFLAGS" => "",
"LDFLAGS" => "",
"LDSHARED" => "cc -shared",
"CCSHARED" => "",
"SHLIB_SUFFIX" => ".so",
"SO" => ".so",
"AR" => "ar",
"ARFLAGS" => "rcs",
"OPT" => "",
"BASECFLAGS" => "",
"BLDSHARED" => "cc -shared",
// Compiler configuration for native extension builds
"CC" => "cc",
"CXX" => "c++",
"CFLAGS" => "",
"CPPFLAGS" => "",
"LDFLAGS" => "",
"LDSHARED" => if cfg!(windows) { "link.exe" } else { "cc -shared" },
"CCSHARED" => "",
"SHLIB_SUFFIX" => if cfg!(windows) { ".dll" } else if cfg!(target_os = "macos") { ".dylib" } else { ".so" },
"SO" => if cfg!(windows) { ".pyd" } else { ".so" },
"AR" => "ar",
"ARFLAGS" => "rcs",
"OPT" => "",
"BASECFLAGS" => "",
"BLDSHARED" => if cfg!(windows) { "link.exe" } else { "cc -shared" },

}
include!(concat!(env!("OUT_DIR"), "/env_vars.rs"));
vars
Expand Down
Loading