Skip to content
Snippets Groups Projects
Unverified Commit 4f7aa50a authored by Cloud Han's avatar Cloud Han Committed by GitHub
Browse files

[build] relax python requirement in cmake build (#4090)

parent a8fc99d0
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,9 @@ include(GNUInstallDirs)
include(Utils)
include(third_party/get_third_party)
# Should update cmake to a more recent version which supports FindPython3.
find_package(PythonInterp)
if(NOT PYTHON_EXECUTABLE OR PYTHON_VERSION_MAJOR LESS 3)
message(WARNING "Needs python3 to auto-generate most CMake files, but not found. "
"Will try `python3` directly...")
set(PYTHON_EXECUTABLE "python3")
if(NOT PYTHON_EXECUTABLE)
message(FATAL_ERROR "Needs python to auto-generate most CMake files, but not found.")
endif()
message(STATUS "Running gen_cmake_skeleton.py")
......
from __future__ import print_function
import os
import sys
import re
import fnmatch
import argparse
# avoid Python>3 rewrite newline on different platforms
os.linesep = "\n"
# earily parse, will refernece args globally
parser = argparse.ArgumentParser()
parser.add_argument("working_dir")
......@@ -308,7 +313,7 @@ class CMakeListsFile(object):
self.sections.append(section)
def write_file(self):
with open(self.path, "w", newline='\n') as f: # good luck for python2
with open(self.path, "w") as f:
f.write(CMakeListsFile.GEN_CMAKE_HEADER)
for s in self.sections:
code = s.gen_code()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment