From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> All python scripts run from cmake should use PYTHON_EXECUTABLE and must support python3. Update gen-sparse's call to this standard. Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> --- CMakeLists.txt | 30 +++++++++++++++--------------- buildlib/RDMA_Sparse.cmake | 2 +- buildlib/gen-sparse.py | 11 ++++++----- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31100e267f2150..cfd4c3cbf9481e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,21 @@ endif() RDMA_BuildType() include_directories(${BUILD_INCLUDE}) +# Look for Python. We prefer some variant of python 3 if the system has it. +FIND_PACKAGE(PythonInterp 3 QUIET) +if (PythonInterp_FOUND) + # pyverbs can only use python3: + if (NO_PYVERBS) + set(CYTHON_EXECUTABLE "") + else() + FIND_PACKAGE(cython) + endif() +else() + # But we still must have python (be it 2) for the build process: + FIND_PACKAGE(PythonInterp REQUIRED) + set(CYTHON_EXECUTABLE "") +endif() + RDMA_CheckSparse() # Require GNU99 mode @@ -364,21 +379,6 @@ else() set(HAVE_FULL_SYMBOL_VERSIONS 1) endif() -# Look for Python. We prefer some variant of python 3 if the system has it. -FIND_PACKAGE(PythonInterp 3 QUIET) -if (PythonInterp_FOUND) - # pyverbs can only use python3: - if (NO_PYVERBS) - set(CYTHON_EXECUTABLE "") - else() - FIND_PACKAGE(cython) - endif() -else() - # But we still must have python (be it 2) for the build process: - FIND_PACKAGE(PythonInterp REQUIRED) - set(CYTHON_EXECUTABLE "") -endif() - # A cython & python-devel installation that matches our selected interpreter. if (CYTHON_EXECUTABLE) diff --git a/buildlib/RDMA_Sparse.cmake b/buildlib/RDMA_Sparse.cmake index 8fcfb758d5284f..3d03ce6283eec4 100644 --- a/buildlib/RDMA_Sparse.cmake +++ b/buildlib/RDMA_Sparse.cmake @@ -19,7 +19,7 @@ int main(int argc,const char *argv[]) {return 0;} set(HAVE_SPARSE TRUE PARENT_SCOPE) # Replace various glibc headers with our own versions that have embedded sparse annotations. - execute_process(COMMAND "${BUILDLIB}/gen-sparse.py" + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${BUILDLIB}/gen-sparse.py" "--out" "${BUILD_INCLUDE}/" "--src" "${CMAKE_SOURCE_DIR}/" RESULT_VARIABLE retcode) diff --git a/buildlib/gen-sparse.py b/buildlib/gen-sparse.py index c289da31c19d75..84781f4528feef 100755 --- a/buildlib/gen-sparse.py +++ b/buildlib/gen-sparse.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2015-2017 Obsidian Research Corp. # Licensed under BSD (MIT variant) or GPLv2. See COPYING. import argparse @@ -66,10 +66,10 @@ def apply_patch(src,patch,dest): subprocess.check_output(["patch","-f","--follow-symlinks","-V","never","-i",patch,"-o",dest,src]); if os.path.exists(dest + ".rej"): - print "Patch from %r failed"%(patch); + print("Patch from %r failed"%(patch)); return False; except subprocess.CalledProcessError: - print "Patch from %r failed"%(patch); + print("Patch from %r failed"%(patch)); return False; return True; @@ -81,7 +81,7 @@ def replace_header(fn): return; tries = tries + 1; - print "Unable to apply any patch to %r, tries %u"%(fn,tries); + print("Unable to apply any patch to %r, tries %u"%(fn,tries)); global failed; failed = True; @@ -119,7 +119,8 @@ args = parser.parse_args(); if args.save: # Get the glibc version string - ver = subprocess.check_output(["ldd","--version"]).splitlines()[0].split(' ')[-1]; + ver = subprocess.check_output(["ldd","--version"]).decode() + ver = ver.splitlines()[0].split(' ')[-1]; ver = ver.partition(".")[-1]; outdir = os.path.join(args.SRC,"buildlib","sparse-include",ver); if not os.path.isdir(outdir): -- 2.21.0