Skip to content

gh-81773: Avoid parsing sys.version string in sysconfig - #146149

Closed
vstinner wants to merge 6 commits into
python:mainfrom
vstinner:sysconfig_py_version
Closed

gh-81773: Avoid parsing sys.version string in sysconfig#146149
vstinner wants to merge 6 commits into
python:mainfrom
vstinner:sysconfig_py_version

Conversation

@vstinner

@vstinnervstinner commented Mar 19, 2026

Copy link
Copy Markdown
Member

No longer parse sys.version string to create sysconfig._PY_VERSION. Add _sysconfig.PY_VERSION constant.

No longer parse sys.version string to create sysconfig._PY_VERSION.
Add _sysconfig._PY_VERSION constant.
@vstinner

Copy link
Copy Markdown
MemberAuthor

cc @FFY00

* Move also py_version_short and py_version_nodot to _sysconfig.
* Use _sysconfig.config_vars() on all platforms, no only Windows.
Comment on lines -534 to -535
_CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
_CONFIG_VARS['py_version_nodot'] = _PY_VERSION_SHORT_NO_DOT

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'm not sure if it's worth it to move py_version_short and py_version_nodot to _sysconfig, since they can be easily built in Python.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I reverted py_version_short and py_version_nodot changes.

@vstinner

Copy link
Copy Markdown
MemberAuthor

Ping @FFY00.

@vstinner

Copy link
Copy Markdown
MemberAuthor

I'm not longer sure that this change is worth it. _PY_VERSION = sys.version.split()[0] just works. I close my PR.

@vstinner
vstinner deleted the sysconfig_py_version branch March 26, 2026 17:33
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@vstinner