Skip to content

CMake build fails without Python3 and Python libraries. #1779

Closed

Description

@phoenix-meadowlark

The CMake build as described in the linux getting started doc fails to build without first installing python and its libraries (e.g. via sudo apt-get install python3 python3-pip python3-setuptools):

CMake Error at /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find PythonInterp: Found unsuitable version "2.7.17", but
  required is at least "3" (found /usr/bin/python)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:443 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.17/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:114 (find_package)


-- Configuring incomplete, errors occurred!
See also "/usr/src/git/iree/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.
CMake Error at /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  (Required is at least version "3")
Call Stack (most recent call first):
  /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.17/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:115 (find_package)


-- Configuring incomplete, errors occurred!
See also "/usr/src/git/iree/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.

Activity

  1. added
    documentation
    infrastructure
    on May 4, 2020
  2. ScottTodd commented on May 5, 2020

    @ScottTodd
    Member

    Here's where we check for Python 3: https://github.com/google/iree/blob/f5c64fabdab88bf96aa4dfe7100a628304327ebe/CMakeLists.txt#L107-L116

    SPIRV-Tools uses python, but we aren't depending on it anymore (I'll remove it soon).

    LLVM also uses Python though, which we can't cut off. Due to incompatibilities, I think we should require python3 installation and add it to the docs.

  3. phoenix-meadowlark commented on May 5, 2020

    @phoenix-meadowlark
    ContributorAuthor

    Sounds good; I'll make the change.

  4. ScottTodd commented on May 6, 2020

    @ScottTodd
    Member

    Adapting some comments from #1778:

    Removing ${IREE_BUILD_COMPILER} from https://github.com/google/iree/blob/d0d81a26221e3c56e2b999f98238f60db7f85b73/CMakeLists.txt#L107-L116

    allows builds to complete without Python 3 installed, now that some dependencies have changed.


    I think we should still prefer Python 3 over Python 2 if both are installed though. Maybe we could set

       find_package(PythonInterp 3 OPTIONAL) 
       find_package(PythonLibs 3 OPTIONAL) 
    

    if IREE_BUILD_PYTHON_BINDINGS is not set, and keep the REQUIRED checks if it is? If we actually depend on Python 3 when not building the Python bindings, then we should always set it as required.

  5. ScottTodd commented on May 11, 2020

    @ScottTodd
    Member

    I'm on a fresh Windows install going through setup now. I don't have Python 2 or 3 installed yet.

    Made this change:

    if(${IREE_BUILD_PYTHON_BINDINGS})
      find_package(PythonInterp 3 REQUIRED)
      find_package(PythonLibs 3 REQUIRED)
    else()
      find_package(PythonInterp 3)
      find_package(PythonLibs 3)
    endif()
    

    Got these logs:

    [cmake] -- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3")
    [cmake] -- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "3")
    [cmake] -- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) 
    ...
    [cmake] -- Could NOT find Python3 (missing: Python3_EXECUTABLE Interpreter) 
    [cmake] CMake Warning at third_party/llvm-project/llvm/CMakeLists.txt:694 (message):
    [cmake]   Python3 not found, using python2 as a fallback
    [cmake] 
    [cmake] 
    [cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
    [cmake]   Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
    [cmake] Call Stack (most recent call first):
    [cmake]   C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
    [cmake]   C:/Program Files/CMake/share/cmake-3.17/Modules/FindPython/Support.cmake:2401 (find_package_handle_standard_args)
    [cmake]   C:/Program Files/CMake/share/cmake-3.17/Modules/FindPython2.cmake:258 (include)
    [cmake]   third_party/llvm-project/llvm/CMakeLists.txt:695 (find_package)
    

    So LLVM requires Python in some form. We actually can't currently build with -DIREE_ENABLE_LLVM=OFF -DIREE_BUILD_COMPILER=OFF -DIREE_BUILD_SAMPLES=OFF right now (iree_bytecode_module tries to pull in iree_tools_iree-translate during configure). I think if that segment of the build were to work, we'd want the optional Python check gated on IREE_ENABLE_LLVM, if anything (just spams logs a bit if it doesn't find it).

    How about this?

    1. Fix CMake configuration to not require Python when IREE_ENABLE_LLVM is OFF (basically runtime-only builds)
    2. Make the find_package calls generally optional, but required when IREE_BUILD_PYTHON_BINDINGS is set
    3. Omit Python setup from Linux docs, where Python 2 is usually installed by default
    4. Include Python setup in Windows docs, where Python is not necessarily installed. Recommend 3.
    5. Include Python 3 setup in Python docs (already done: https://google.github.io/iree/GetStarted/Python#python-setup)
  6. marbre commented on May 11, 2020

    @marbre
    Member

    Just a short note on the fixing the CMake to not require Python. Beside iree_bytecode_module, I think we cannot pass -DIREE_ENABLE_LLVM=OFF due to requiring iree-tblgen for the runtime. This pulls in the dep on LLVM, see #357.

  7. ScottTodd commented on May 11, 2020

    @ScottTodd
    Member

    Just a short note on the fixing the CMake to not require Python. Beside iree_bytecode_module, I think we cannot pass -DIREE_ENABLE_LLVM=OFF due to requiring iree-tblgen for the runtime. This pulls in the dep on LLVM, see #357.

    Yep, that's the next issue I hit :P

  8. benvanik commented on Nov 22, 2020

    @benvanik
    Collaborator

    Obsolete?

  9. ScottTodd commented on Aug 31, 2021

    @ScottTodd
    Member

    Obsolete?

    Yeah let's just close this... there might still be issues, but I haven't heard complaints about Python installations in a while.

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

Metadata

Metadata

Labels

documentationinfrastructure

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions