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
EXT_SUFFIX
  • Loading branch information
youknowone committed Dec 8, 2025
commit 8623b750d6592edcf48645dbd5d2b1eee73edabd
1 change: 1 addition & 0 deletions .cspell.dict/cpython.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ prec
preinitialized
PYTHREAD_NAME
SA_ONSTACK
SOABI
stackdepth
stringlib
structseq
Expand Down
11 changes: 11 additions & 0 deletions crates/vm/src/stdlib/sysconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ pub(crate) mod sysconfig {
#[pyfunction]
fn config_vars(vm: &VirtualMachine) -> PyDictRef {
let vars = vm.ctx.new_dict();

// FIXME: This is an entirely wrong implementation of EXT_SUFFIX.
// EXT_SUFFIX must be a string starting with "." for pip compatibility
// Using ".pyd" causes pip's _generic_abi() to fall back to _cpython_abis()
vars.set_item("EXT_SUFFIX", ".pyd".to_pyobject(vm), vm)
.unwrap();
vars.set_item("SOABI", vm.ctx.none(), vm).unwrap();

vars.set_item("Py_GIL_DISABLED", true.to_pyobject(vm), vm)
.unwrap();
vars.set_item("Py_DEBUG", false.to_pyobject(vm), vm)
.unwrap();
Comment on lines +10 to +21
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

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the sysconfig.rs file to see its full context
wc -l crates/vm/src/stdlib/sysconfig.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the complete sysconfig.rs file and its module definition
cat -n crates/vm/src/stdlib/sysconfig.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Search for how sysconfig is registered/loaded and any platform guards
rg -n "sysconfig" crates/vm/src/stdlib/ --type rust -B 3 -A 3

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check for platform-specific gates on sysconfig module
rg -n "#\[cfg" crates/vm/src/stdlib/sysconfig.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Search for EXT_SUFFIX usage across the codebase
rg -n "EXT_SUFFIX" crates/vm/src/ --type rust -B 2 -A 2

Repository: RustPython/RustPython

Length of output: 186


🌐 Web query:

CPython sysconfig EXT_SUFFIX platform specific Windows Unix macOS

💡 Result:

Short summary — what EXT_SUFFIX is and platform differences, and how to get it:

  • EXT_SUFFIX is the filename suffix used for compiled Python extension modules (shared objects) for the current build — e.g. on POSIX you usually get .cpython-XY... .so (includes the SOABI), on Windows you get .pyd (often with a platform/ABI tag like .cp37-win_amd64.pyd when full suffix is available). [1][2]

  • How CPython exposes it:

    • sysconfig.get_config_var('EXT_SUFFIX') — canonical API to query the extension suffix. On many Unix/macOS builds this returns the full tagged suffix (e.g. ".cpython-39m-darwin.so"). On some Windows builds it may return only ".pyd" (SOABI may be None). [2][5]
    • If you need the fuller Windows tag (e.g. ".cp37-win_amd64.pyd"), distutils.sysconfig.get_config_var('EXT_SUFFIX') historically returned the full value on Windows in some builds (useful as a fallback). Note: distutils is deprecated but still present in many Python versions; prefer sysconfig when possible. [0]
  • Practical snippet:

    • import sysconfig; ext = sysconfig.get_config_var('EXT_SUFFIX')
    • fallback (Windows): import distutils.sysconfig; ext = distutils.sysconfig.get_config_var('EXT_SUFFIX') if ext is None or ext == '.pyd' else ext. [0][1]

References:

  • Python sysconfig docs (describe get_config_var / get_platform / usage). [1][2]
  • StackOverflow discussion showing Windows behavior and distutils fallback. [0]

Sources:
[0] StackOverflow — "Python generate SOABI/Extension Suffix (pep 3149) for Windows".
[1] Python docs — sysconfig (library documentation).
[2] Python docs — Configure/using Python (notes on platform/config).


🌐 Web query:

RustPython sysconfig module EXT_SUFFIX implementation

💡 Result:

Do you want (a) the RustPython source location that implements sysconfig/EXT_SUFFIX, (b) an explanation of how EXT_SUFFIX should behave (CPython behaviour), or (c) help implementing/fixing EXT_SUFFIX in RustPython?


Hardcoded .pyd EXT_SUFFIX will break on Unix/macOS platforms.

EXT_SUFFIX must be platform-specific: Windows uses .pyd, while Unix/macOS require .cpython-XY-{platform}.so with SOABI included. The current hardcoded .pyd value will cause extension module discovery to fail on non-Windows platforms.

Ensure either:

  1. This module is Windows-only (gated with #[cfg(windows)]), or
  2. EXT_SUFFIX is set conditionally based on the target platform, with appropriate SOABI values for Unix/macOS
🤖 Prompt for AI Agents
crates/vm/src/stdlib/sysconfig.rs lines 10-21: the code hardcodes EXT_SUFFIX to
".pyd" which is only valid on Windows and misses SOABI for Unix/macOS; change
this by gating the Windows-specific assignment behind #[cfg(windows)] (or
runtime cfg!(windows)) and for non-Windows targets set EXT_SUFFIX to a
dot-prefixed SO filename (e.g. the cpython-style suffix that includes
ABI/version and platform) and populate SOABI with the corresponding value;
ensure EXT_SUFFIX always begins with '.' for pip compatibility and
unwrap/error-handle setters as before.


vars
}
}