You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CMake build fails without Python3 and Python libraries. #1779
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.
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.
[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?
Fix CMake configuration to not require Python when IREE_ENABLE_LLVM is OFF (basically runtime-only builds)
Make the find_package calls generally optional, but required when IREE_BUILD_PYTHON_BINDINGS is set
Omit Python setup from Linux docs, where Python 2 is usually installed by default
Include Python setup in Windows docs, where Python is not necessarily installed. Recommend 3.
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.
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.
Activity
ScottTodd commentedon May 5, 2020
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.
phoenix-meadowlark commentedon May 5, 2020
Sounds good; I'll make the change.
ScottTodd commentedon May 6, 2020
Adapting some comments from #1778:
Removing
${IREE_BUILD_COMPILER}from https://github.com/google/iree/blob/d0d81a26221e3c56e2b999f98238f60db7f85b73/CMakeLists.txt#L107-L116allows 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
if
IREE_BUILD_PYTHON_BINDINGSis not set, and keep theREQUIREDchecks if it is? If we actually depend on Python 3 when not building the Python bindings, then we should always set it as required.ScottTodd commentedon May 11, 2020
I'm on a fresh Windows install going through setup now. I don't have Python 2 or 3 installed yet.
Made this change:
Got these logs:
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=OFFright now (iree_bytecode_moduletries to pull iniree_tools_iree-translateduring configure). I think if that segment of the build were to work, we'd want the optional Python check gated onIREE_ENABLE_LLVM, if anything (just spams logs a bit if it doesn't find it).How about this?
IREE_ENABLE_LLVMisOFF(basically runtime-only builds)find_packagecalls generally optional, but required whenIREE_BUILD_PYTHON_BINDINGSis setmarbre commentedon May 11, 2020
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=OFFdue to requiringiree-tblgenfor the runtime. This pulls in the dep on LLVM, see #357.ScottTodd commentedon May 11, 2020
Yep, that's the next issue I hit :P
Add guards around more components which require building the compiler.
benvanik commentedon Nov 22, 2020
Obsolete?
ScottTodd commentedon Aug 31, 2021
Yeah let's just close this... there might still be issues, but I haven't heard complaints about Python installations in a while.