Skip to content

Commit

Permalink
[python] try to use bundled distutils to setuptools during setup (#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Aug 11, 2020
1 parent e6bf409 commit 97d5758
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""Setup lightgbm package."""
from __future__ import absolute_import

import distutils
import io
import logging
import os
Expand All @@ -16,6 +15,8 @@
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():
Expand All @@ -35,7 +36,7 @@ def copy_files_helper(folder_name):
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))

Expand All @@ -44,20 +45,20 @@ def copy_files_helper(folder_name):
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"),
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"),
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.vcxproj"),
verbose=0)
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "windows", "LightGBM.sln"),
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"),
verbose=0)
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"),
os.path.join(CURRENT_DIR, "compile", "CMakeLists.txt"),
verbose=0)
distutils.file_util.copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "LICENSE"),
os.path.join(CURRENT_DIR, "LICENSE"),
verbose=0)
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "CMakeLists.txt"),
os.path.join(CURRENT_DIR, "compile", "CMakeLists.txt"),
verbose=0)
copy_file(os.path.join(CURRENT_DIR, os.path.pardir, "LICENSE"),
os.path.join(CURRENT_DIR, "LICENSE"),
verbose=0)


def clear_path(path):
Expand Down Expand Up @@ -258,9 +259,9 @@ def run(self):
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'),
os.path.join(CURRENT_DIR, 'lightgbm', 'VERSION.txt'),
verbose=0)
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()
readme = io.open(os.path.join(CURRENT_DIR, 'README.rst'), encoding='utf-8').read()

Expand Down

0 comments on commit 97d5758

Please sign in to comment.