Skip to content

sysconfig should not rely on sys.version #81773

Closed

Description

@carlbordum
BPO 37592
Nosy @tarekziade, @carlbordum
PRs
  • bpo-37592: sysconfig no longer relies on sys.version #14776
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2019-07-14.14:18:09.238>
    labels = ['type-feature', 'library', '3.9']
    title = 'sysconfig should not rely on sys.version'
    updated_at = <Date 2019-07-14.14:20:50.854>
    user = 'https://github.com/carlbordum'

    bugs.python.org fields:

    activity = <Date 2019-07-14.14:20:50.854>
    actor = 'carlbordum'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-07-14.14:18:09.238>
    creator = 'carlbordum'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37592
    keywords = ['patch']
    message_count = 1.0
    messages = ['347916']
    nosy_count = 2.0
    nosy_names = ['tarek', 'carlbordum']
    pr_nums = ['14776']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37592'
    versions = ['Python 3.9']

    Linked PRs

    Activity

    1. carlbordum commented on Jul 14, 2019

      carlbordummannequin
      MannequinAuthor

      I found this FIXME and replaced it with code that follows the git tags naming scheme.

    2. added
      3.9 (EOL)
      stdlib
      type-feature
      on Jul 14, 2019
    3. transferred this issue fromon Apr 10, 2022
    4. mattip commented on Nov 16, 2022

      @mattip
      Contributor

      PR #14776 was closed, deferring to PR #24644 so I think this issue should be closed.

    5. FFY00 commented on Nov 21, 2022

      @FFY00
      Member

      No, it is still used to calculate _PY_VERSION, and is also used in get_platform, which the original PR did not touch. I don't think it's a huge issue, but as the documentation advises us to not extract information from it, we should replace such usages.

    6. FFY00 commented on Nov 21, 2022

      @FFY00
      Member

      _PY_VERSION = sys.version.split()[0]

      cpython/Lib/sysconfig.py

      Lines 765 to 770 in 6d8da23

      if 'amd64' in sys.version.lower():
      return 'win-amd64'
      if '(arm)' in sys.version.lower():
      return 'win-arm32'
      if '(arm64)' in sys.version.lower():
      return 'win-arm64'

    7. vstinner commented on Mar 19, 2026

      @vstinner
      Member
       if 'amd64' in sys.version.lower(): 
           return 'win-amd64' 
       if '(arm)' in sys.version.lower(): 
           return 'win-arm32' 
       if '(arm64)' in sys.version.lower(): 
           return 'win-arm64' 

      I removed this code in PR gh-146145 which adds _sysconfig.get_platform() on Windows.

      The last line using sys.version in sysconfig is: _PY_VERSION = sys.version.split()[0].

    8. added a commit that references this issue on Mar 19, 2026
    9. vstinner commented on Mar 19, 2026

      @vstinner
      Member

      I created #146149 to add _sysconfig._PY_VERSION.

    10. vstinner commented on Mar 26, 2026

      @vstinner
      Member

      @FFY00:

      No, it is still used to calculate _PY_VERSION, and is also used in get_platform, which the original PR did not touch. I don't think it's a huge issue, but as the documentation advises us to not extract information from it, we should replace such usages.

      I wrote #146149 but I'm not sure that this change is worth it. _PY_VERSION = sys.version.split()[0] just works. I prefer to just close this issue.

      Reopen it if you consider that sysconfig should really not parse sys.version string (to set _PY_VERSION).

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)stdlibtype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions