Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysconfig.get_config_vars() values always get overwritten with the values from Makefile #126920

Closed
FFY00 opened this issue Nov 17, 2024 · 0 comments
Labels
topic-sysconfig type-bug An unexpected behavior, bug, or error

Comments

@FFY00
Copy link
Member

FFY00 commented Nov 17, 2024

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,

_CONFIG_VARS['prefix'] = _PREFIX # FIXME: This gets overwriten by _init_posix.
_CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX # FIXME: This gets overwriten by _init_posix.

vars.update(build_time_vars)

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

Linked PRs

@FFY00 FFY00 added type-bug An unexpected behavior, bug, or error topic-sysconfig labels Nov 17, 2024
FFY00 added a commit to FFY00/cpython that referenced this issue Nov 17, 2024
…m the Makefile

Signed-off-by: Filipe Laíns <lains@riseup.net>
FFY00 added a commit to FFY00/cpython that referenced this issue Nov 17, 2024
Signed-off-by: Filipe Laíns <lains@riseup.net>
@FFY00 FFY00 closed this as completed Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-sysconfig type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant