Bail out early if libxgboost exists in python setup (#6694)

Skip `copy_tree` when existing build is found.
This commit is contained in:
Ali 2021-02-09 18:50:10 -08:00 committed by GitHub
parent e8c5c53e2f
commit 9b267a435e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,12 +129,6 @@ class BuildExt(build_ext.build_ext): # pylint: disable=too-many-ancestors
self.logger.info('Using system libxgboost.')
return
src_dir = 'xgboost'
try:
copy_tree(os.path.join(CURRENT_DIR, os.path.pardir),
os.path.join(self.build_temp, src_dir))
except Exception: # pylint: disable=broad-except
copy_tree(src_dir, os.path.join(self.build_temp, src_dir))
build_dir = self.build_temp
global BUILD_TEMP_DIR # pylint: disable=global-statement
BUILD_TEMP_DIR = build_dir
@ -145,6 +139,13 @@ class BuildExt(build_ext.build_ext): # pylint: disable=too-many-ancestors
self.logger.info('Found shared library, skipping build.')
return
src_dir = 'xgboost'
try:
copy_tree(os.path.join(CURRENT_DIR, os.path.pardir),
os.path.join(self.build_temp, src_dir))
except Exception: # pylint: disable=broad-except
copy_tree(src_dir, os.path.join(self.build_temp, src_dir))
self.logger.info('Building from source. %s', libxgboost)
if not os.path.exists(build_dir):
os.mkdir(build_dir)