From 9b267a435e0aa1dfdff211d1a5b668538c51cd35 Mon Sep 17 00:00:00 2001 From: Ali <320322+ali5h@users.noreply.github.com> Date: Tue, 9 Feb 2021 18:50:10 -0800 Subject: [PATCH] Bail out early if libxgboost exists in python setup (#6694) Skip `copy_tree` when existing build is found. --- python-package/setup.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python-package/setup.py b/python-package/setup.py index ae8892519..a2feb7667 100644 --- a/python-package/setup.py +++ b/python-package/setup.py @@ -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)