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

No "Shiboken2Config.*.cmake" File Installed for Python 2.7

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.6
    • 5.6
    • PySide, Shiboken
    • None
    • Python: 2.7; OS: Gentoo Linux
    • 8ae4d5827d1ccd463b99aaf54c2e8cb482094c91

    Description

      Bothersome leycec here with more small-minded installation woes raining on everyone's Qt parade.

      My esteemed colleague Pesa notes that Shiboken2 fails to install a .cmake file when building against Python 2.7. This is, of course, bad.

      The underlying reason appears to be that the PYTHON_EXTENSION_SUFFIX CMake variable is empty under Python 2.7 but not 3.x. The data/CMakeFiles.txt file interpolates this variable into various installation pathnames, including the absolute path of the .cmake file specific to the target Python version being built against. Lines 13 and 14 seem to be the dirty culprit:

      configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Shiboken2Config-spec.cmake.in"
                     "${CMAKE_CURRENT_BINARY_DIR}/Shiboken2Config${PYTHON_EXTENSION_SUFFIX}.cmake" @ONLY)
      

      Under Python 2.7, CMake output exhibiting the horrifying emptiness of both PYTHON_EXTENSION_SUFFIX and modern capitalist society includes:

      cmake -C /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python2_7/gentoo_common_config.cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=no -DPYTHON_EXECUTABLE=/usr/bin/python2.7 -DPYTHON_SITE_PACKAGES=/usr/lib64/python2.7/site-packages -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python2_7/gentoo_rules.cmake -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python2_7/gentoo_toolchain.cmake  /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999
      loading initial cache file /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python2_7/gentoo_common_config.cmake
      -- The C compiler identification is GNU 4.9.4
      -- The CXX compiler identification is GNU 4.9.4
      -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc
      -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++
      -- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonLibs: /usr/lib64/libpython2.7.so (found suitable version "2.7.12", minimum required is "2.6") 
      -- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.6") 
      PYTHONLIBS_FOUND: TRUE
      PYTHON_LIBRARIES: /usr/lib64/libpython2.7.so
      PYTHON_INCLUDE_DIRS: /usr/include/python2.7
      PYTHON_DEBUG_LIBRARIES: 
      PYTHONINTERP_FOUND: TRUE
      PYTHON_EXECUTABLE: /usr/bin/python2.7
      PYTHON_VERSION: 2.7.12
      PYTHON_MULTIARCH_SUFFIX: 
      PYTHON_MODULE_RELEASE_SUFFIX: 
      -- PYTHON_EXTENSION_SUFFIX: 
      -- Found LibXml2: /usr/lib64/libxml2.so (found suitable version "2.9.4", minimum required is "2.6.32") 
      -- Found LibXslt: /usr/lib64/libxslt.so (found suitable version "1.1.29", minimum required is "1.1.19") 
      -- sphinx-build - found
      -- <<< Gentoo configuration >>>
      Build type      Gentoo
      Install path    /usr
      Compiler flags:
      C               -march=native -O2 -pipe
      C++             -march=native -O2 -pipe -Wall -fvisibility=hidden -Wno-strict-aliasing -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII
      Linker flags:
      Executable      -Wl,-O1 -Wl,--as-needed
      Module          -Wl,-O1 -Wl,--as-needed
      Shared          -Wl,-O1 -Wl,--as-needed
      

      Note the vaguely suspicious line -- PYTHON_EXTENSION_SUFFIX:. Under Python 3.4, CMake output shows PYTHON_EXTENSION_SUFFIX to be non-empty:

      cmake -C /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python3_4/gentoo_common_config.cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=no -DPYTHON_EXECUTABLE=/usr/bin/python3.4 -DPYTHON_SITE_PACKAGES=/usr/lib64/python3.4/site-packages -DUSE_PYTHON_VERSION=3 -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python3_4/gentoo_rules.cmake -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python3_4/gentoo_toolchain.cmake  /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999
      loading initial cache file /var/tmp/portage/dev-python/shiboken-9999/work/shiboken-9999-python3_4/gentoo_common_config.cmake
      -- The C compiler identification is GNU 4.9.4
      -- The CXX compiler identification is GNU 4.9.4
      -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc
      -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++
      -- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonLibs: /usr/lib64/libpython3.4m.so (found suitable version "3.4.5", minimum required is "3") 
      -- Found PythonInterp: /usr/bin/python3.4 (found suitable version "3.4.5", minimum required is "3") 
      PYTHONLIBS_FOUND: TRUE
      PYTHON_LIBRARIES: /usr/lib64/libpython3.4m.so
      PYTHON_INCLUDE_DIRS: /usr/include/python3.4m
      PYTHON_DEBUG_LIBRARIES: 
      PYTHONINTERP_FOUND: TRUE
      PYTHON_EXECUTABLE: /usr/bin/python3.4
      PYTHON_VERSION: 3.4.5
      PYTHON_MULTIARCH_SUFFIX: 
      PYTHON_ABI_FLAGS: m
      -- PYTHON_EXTENSION_SUFFIX: .cpython-34m
      -- Found LibXml2: /usr/lib64/libxml2.so (found suitable version "2.9.4", minimum required is "2.6.32") 
      -- Found LibXslt: /usr/lib64/libxslt.so (found suitable version "1.1.29", minimum required is "1.1.19") 
      -- sphinx-build - found
      -- <<< Gentoo configuration >>>
      Build type      Gentoo
      Install path    /usr
      Compiler flags:
      C               -march=native -O2 -pipe
      C++             -march=native -O2 -pipe -Wall -fvisibility=hidden -Wno-strict-aliasing -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_TO_ASCII
      Linker flags:
      Executable      -Wl,-O1 -Wl,--as-needed
      Module          -Wl,-O1 -Wl,--as-needed
      Shared          -Wl,-O1 -Wl,--as-needed
      

      Note the auspicious line -- PYTHON_EXTENSION_SUFFIX: .cpython-34m. Unsurprisingly, a .cmake file is installed for Python 3.4 but not 2.7. After installing shiboken2 against both versions of Python, the contents of /usr/lib64/cmake/Shiboken2-2.0.0 show a .cmake file only for Python 3.4:

      $ ls /usr/lib64/cmake/Shiboken2-2.0.0/
      /usr/lib64/cmake/Shiboken2-2.0.0/Shiboken2Config.cmake
      /usr/lib64/cmake/Shiboken2-2.0.0/Shiboken2Config.cpython-34m.cmake
      /usr/lib64/cmake/Shiboken2-2.0.0/Shiboken2ConfigVersion.cmake
      

      Since nobody really cares about Python 2.7 anymore, this isn't the calamity it might otherwise be. Somebody probably cares, however. They're out there. And they're gritting their teeth as we speak.

      Since you're a gentleman and a scholar, Christian, I decided to dig slightly deeper. The real underlying reason appears to be that the top-level CMakeFiles.txt file incorrectly detects the PYTHON_EXTENSION_SUFFIX for Python 2.7. Why? Because the get_python2_release_suffix() macro sucks badly.

      It's bad and it's original author should feel bad. The macro erroneously detects the desired suffix with the following broken Python 2.7 snippet:

      if True:
          import imp
          print('_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else '')
      

      The problem is the else ''. Actually, the whole snippet is the problem. Even _d doesn't seem particularly unique to Python 2.7. Ideally, a Python 2.7-specific substring should be prepended or appended to the output. For example, to preserve parity with the Python 3.x naming scheme, you might prefix the output by the lowercase name and version of the active Python 2.7 interpreter: e.g.,

      if True:
          import imp, platform
          print('%s-27%s' % (
              platform.python_implementation().lower(),
              '_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else ''))
      

      I am lazy, fat, and tired. I'm also unsure how you'd like to resolve this. So, I probably won't submit a pull request. Hopefully, this is enough to speed you on your perilous journey into the ugly bowels of CMake.

      Thus ends the issue report that would not end.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            alexandru.croitor Alexandru Croitor
            leycec Cecil Curry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes