Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1841

Python 3.7/Windows: wrong python extension suffix in ShibokenHelpers cmake

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • None
    • 6.2.3
    • Shiboken
    • None
    • Python 3.7, Visual Studio 2019, Qt 6.2.3
    • Windows
    • 96b84fe6c7 (pyside/pyside-setup/6.2) d8791e4f5a (pyside/pyside-setup/dev) 96b84fe6c7 (pyside/tqtc-pyside-setup/6.2) d8791e4f5a (pyside/tqtc-pyside-setup/dev)

    Description

      While trying to build PySide6 from source under Visual Studio 2019 a colleague and I came across a potential bug in the build system. In the pyside-setup repository (checked out tag 6.2.3) in the file pyside-setup\sources\shiboken6\cmake\ShibokenHelpers.cmake

      There is a small python snippet executed to extract the extension from sysconfig.get_config_var('EXT_SUFFIX').
      In the current code this is done via rfind('.')

      On our system the variable was however set to the value '.cp39-win_amd64.pyd', which fails the following test if pos > 0, as the first character in the string is a '.'.
      The current code reports Unable to determine PYTHON_EXTENSION_SUFFIX from EXT_SUFFIX: ""

      This can be remedied by using this regex that my colleague wrote for example:
      import re
      import sysconfig
      suffix = sysconfig.get_config_var('EXT_SUFFIX')
      res = re.search(r'^(.*)
      .(.+)', suffix)

      if res:
          suffix = res.group(2)
      else:
          suffix = ''
              print(f'Unable to determine PYTHON_EXTENSION_SUFFIX from EXT_SUFFIX: \"{suffix}\"', file=sys.stderr)

      print(suffix)

      Which prints
      .cp39-win_amd64.pyd

      Attachments

        1. pyside1841.py
          0.3 kB
          Friedemann Kleint
        2. qt_pyside_py37_sysconfig.py
          0.6 kB
          Tim Elberfeld
        For Gerrit Dashboard: PYSIDE-1841
        # Subject Branch Project Status CR V

        Activity

          People

            kleint Friedemann Kleint
            meetaig Tim Elberfeld
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes