Unverified Commit 97d5758f authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[python] try to use bundled distutils to setuptools during setup (#3294)

parent e6bf4090
......@@ -2,7 +2,6 @@
"""Setup lightgbm package."""
from __future__ import absolute_import
import distutils
import io
import logging
import os
......@@ -16,6 +15,8 @@ from setuptools import find_packages, setup
from setuptools.command.install import install
from setuptools.command.install_lib import install_lib
from setuptools.command.sdist import sdist
from distutils.dir_util import copy_tree
from distutils.file_util import copy_file
def find_lib():
......@@ -35,7 +36,7 @@ def copy_files(use_gpu=False):
if os.path.exists(src):
dst = os.path.join(CURRENT_DIR, 'compile', folder_name)
shutil.rmtree(dst, ignore_errors=True)
distutils.dir_util.copy_tree(src, dst, verbose=0)
copy_tree(src, dst, verbose=0)
else:
raise Exception('Cannot copy {0} folder'.format(src))
......@@ -44,18 +45,18 @@ def copy_files(use_gpu=False):
copy_files_helper('src')
if not os.path.exists(os.path.join(CURRENT_DIR, "compile", "windows")):
os.makedirs(os.path.join(CURRENT_DIR, "compile", "windows"))
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "windows", "LightGBM.sln"),
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "windows", "LightGBM.sln"),
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"),
verbose=0)
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "windows", "LightGBM.vcxproj"),
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "windows", "LightGBM.vcxproj"),
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.vcxproj"),
verbose=0)
if use_gpu:
copy_files_helper('compute')
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "CMakeLists.txt"),
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "CMakeLists.txt"),
os.path.join(CURRENT_DIR, "compile", "CMakeLists.txt"),
verbose=0)
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "LICENSE"),
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "LICENSE"),
os.path.join(CURRENT_DIR, "LICENSE"),
verbose=0)
......@@ -258,7 +259,7 @@ if __name__ == "__main__":
LOG_PATH = os.path.join(os.path.expanduser('~'), 'LightGBM_compilation.log')
LOG_NOTICE = "The full version of error log was saved into {0}".format(LOG_PATH)
if os.path.isfile(os.path.join(CURRENT_DIR, os.path.pardir, 'VERSION.txt')):
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, 'VERSION.txt'),
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, 'VERSION.txt'),
os.path.join(CURRENT_DIR, 'lightgbm', 'VERSION.txt'),
verbose=0)
version = io.open(os.path.join(CURRENT_DIR, 'lightgbm', 'VERSION.txt'), encoding='utf-8').read().strip()
......
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