Skip to content

Commit

Permalink
Bail out early if libxgboost exists in python setup (#6694)
Browse files Browse the repository at this point in the history
Skip `copy_tree` when existing build is found.
  • Loading branch information
ali5h authored Feb 10, 2021
1 parent e8c5c53 commit 9b267a4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ def build_cmake_extension(self):
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
Expand All @@ -145,6 +139,13 @@ def build_cmake_extension(self):
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)
Expand Down

0 comments on commit 9b267a4

Please sign in to comment.