Description
Bug report
Bug description:
When fixing GH-126789, I noticed the exec
and exec_prefix
keys from sysconfig.get_config_vars()
always get set to the value from Makefile
, instead of following sys.prefix
and sys.exec_prefix
.
This happens because, after we set the values from sys.prefix
and sys.exec_prefix
in sysconfig._init_config_vars()
, sysconfig._init_posix()
updates the dictionary with the values from the Makefile
, overwriting any values we set previously,
cpython/Lib/sysconfig/__init__.py
Lines 469 to 470 in acbd5c9
cpython/Lib/sysconfig/__init__.py
Line 356 in acbd5c9
From my testing, exec
and exec_prefix
seem to be only the only keys currently affected, and fortunately they aren't used to calculate any of the sysconfig.get_paths()
paths, which is probably why we didn't notice earlier.
I should also note that since the sys
values only differ from the ones in the Makefile
on virtual environments, this bug only happens inside virtual environments.
That said, the current code makes things super fragile. Just creating a variable name base
in the Makefile
, for eg., would majorly break sysconfig.get_paths()
in virtual environments.
The fix is pretty simple, the values from the Makefile
should not overwrite any of the values we previously set.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response