Commit 96cb6984 authored by Guolin Ke's avatar Guolin Ke Committed by Nikita Titov
Browse files

[python] add option to disable openmp in python package build (#1780)

* add option to disable openmp in python package build

* fix pylint
parent 9487f5c7
...@@ -87,10 +87,10 @@ def silent_call(cmd, raise_error=False, error_msg=''): ...@@ -87,10 +87,10 @@ def silent_call(cmd, raise_error=False, error_msg=''):
return 1 return 1
def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, use_hdfs=False, def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False,
boost_root=None, boost_dir=None, boost_include_dir=None, use_hdfs=False, boost_root=None, boost_dir=None,
boost_librarydir=None, opencl_include_dir=None, boost_include_dir=None, boost_librarydir=None,
opencl_library=None): opencl_include_dir=None, opencl_library=None):
if os.path.exists(os.path.join(CURRENT_DIR, "build_cpp")): if os.path.exists(os.path.join(CURRENT_DIR, "build_cpp")):
shutil.rmtree(os.path.join(CURRENT_DIR, "build_cpp")) shutil.rmtree(os.path.join(CURRENT_DIR, "build_cpp"))
...@@ -116,6 +116,8 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, use_hdfs=False, ...@@ -116,6 +116,8 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, use_hdfs=False,
cmake_cmd.append("-DOpenCL_LIBRARY={0}".format(opencl_library)) cmake_cmd.append("-DOpenCL_LIBRARY={0}".format(opencl_library))
if use_mpi: if use_mpi:
cmake_cmd.append("-DUSE_MPI=ON") cmake_cmd.append("-DUSE_MPI=ON")
if nomp:
cmake_cmd.append("-DUSE_OPENMP=OFF")
if use_hdfs: if use_hdfs:
cmake_cmd.append("-DUSE_HDFS=ON") cmake_cmd.append("-DUSE_HDFS=ON")
if system() in ('Windows', 'Microsoft'): if system() in ('Windows', 'Microsoft'):
...@@ -184,6 +186,7 @@ class CustomInstall(install): ...@@ -184,6 +186,7 @@ class CustomInstall(install):
('mingw', 'm', 'Compile with MinGW'), ('mingw', 'm', 'Compile with MinGW'),
('gpu', 'g', 'Compile GPU version'), ('gpu', 'g', 'Compile GPU version'),
('mpi', None, 'Compile MPI version'), ('mpi', None, 'Compile MPI version'),
('nomp', None, 'Compile without openmp'),
('hdfs', 'h', 'Compile HDFS version'), ('hdfs', 'h', 'Compile HDFS version'),
('precompile', 'p', 'Use precompiled library'), ('precompile', 'p', 'Use precompiled library'),
('boost-root=', None, 'Boost preferred installation prefix'), ('boost-root=', None, 'Boost preferred installation prefix'),
...@@ -207,13 +210,14 @@ class CustomInstall(install): ...@@ -207,13 +210,14 @@ class CustomInstall(install):
self.mpi = 0 self.mpi = 0
self.hdfs = 0 self.hdfs = 0
self.precompile = 0 self.precompile = 0
self.nomp = 0
def run(self): def run(self):
open(LOG_PATH, 'wb').close() open(LOG_PATH, 'wb').close()
if not self.precompile: if not self.precompile:
copy_files(use_gpu=self.gpu) copy_files(use_gpu=self.gpu)
compile_cpp(use_mingw=self.mingw, use_gpu=self.gpu, use_mpi=self.mpi, use_hdfs=self.hdfs, compile_cpp(use_mingw=self.mingw, use_gpu=self.gpu, use_mpi=self.mpi, nomp=self.nomp,
boost_root=self.boost_root, boost_dir=self.boost_dir, use_hdfs=self.hdfs, boost_root=self.boost_root, boost_dir=self.boost_dir,
boost_include_dir=self.boost_include_dir, boost_librarydir=self.boost_librarydir, boost_include_dir=self.boost_include_dir, boost_librarydir=self.boost_librarydir,
opencl_include_dir=self.opencl_include_dir, opencl_library=self.opencl_library) opencl_include_dir=self.opencl_include_dir, opencl_library=self.opencl_library)
install.run(self) install.run(self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment