[python] [setup] removing source files (#898)

* travis cleanup

* removed precompiled files in windows folder from sdist command

* removed rubbish from install folder

* added compute folder
This commit is contained in:
Nikita Titov 2017-09-10 03:27:48 +03:00 коммит произвёл Guolin Ke
Родитель 8984111f05
Коммит 9eab7ec8df
5 изменённых файлов: 41 добавлений и 29 удалений

Просмотреть файл

@ -2,6 +2,9 @@ language: cpp
sudo: required
dist: trusty
git:
submodules: true
compiler:
- gcc
@ -10,15 +13,17 @@ os:
- osx
env:
global:
- PYTHON_VERSION=3.6
matrix:
- TASK=regular PYTHON_VERSION=3.6
- TASK=mpi PYTHON_VERSION=3.6
- TASK=pylint PYTHON_VERSION=3.6
- TASK=if-else PYTHON_VERSION=3.6
- TASK=sdist PYTHON_VERSION=3.6
- TASK=bdist PYTHON_VERSION=3.6
- TASK=gpu METHOD=source PYTHON_VERSION=3.6
- TASK=gpu METHOD=pip PYTHON_VERSION=3.6
- TASK=regular
- TASK=mpi
- TASK=pylint
- TASK=if-else
- TASK=sdist
- TASK=bdist
- TASK=gpu METHOD=source
- TASK=gpu METHOD=pip
- TASK=regular PYTHON_VERSION=2.7
- TASK=regular PYTHON_VERSION=3.4
- TASK=regular PYTHON_VERSION=3.5
@ -26,11 +31,11 @@ env:
matrix:
exclude:
- os: osx
env: TASK=gpu METHOD=source PYTHON_VERSION=3.6
env: TASK=gpu METHOD=source
- os: osx
env: TASK=gpu METHOD=pip PYTHON_VERSION=3.6
env: TASK=gpu METHOD=pip
- os: osx
env: TASK=pylint PYTHON_VERSION=3.6
env: TASK=pylint
before_install:
- test -n $CC && unset CC

Просмотреть файл

@ -14,6 +14,7 @@ environment:
clone_depth: 50
install:
- git submodule update --init --recursive # get `compute` folder
- set PATH=%PATH:C:\Program Files\Git\usr\bin;=% # Delete sh.exe from PATH (mingw32-make fix)
- set PATH=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
- set PYTHON_VERSION=%CONFIGURATION%

Просмотреть файл

@ -2,9 +2,11 @@ prune build
include LICENSE
include *.rst *.txt
recursive-include lightgbm *.py *.txt *.so
recursive-include lightgbm/Release *.dll
recursive-include lightgbm/include *
recursive-include lightgbm/src *
recursive-include lightgbm/windows LightGBM.sln LightGBM.vcxproj LightGBM.vcxproj.filters
recursive-include lightgbm/windows/x64/DLL *.dll
recursive-include compile *.txt *.so
recursive-include compile/Release *.dll
recursive-include compile/compute *
recursive-include compile/include *
recursive-include compile/src *
recursive-include compile/windows LightGBM.sln LightGBM.vcxproj LightGBM.vcxproj.filters
recursive-include compile/windows/x64/DLL *.dll
global-exclude *.py[co]

Просмотреть файл

@ -16,10 +16,13 @@ def find_lib_path():
return []
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
dll_path = [curr_path, os.path.join(curr_path, '../../'), os.path.join(curr_path, '../../lib/')]
dll_path = [curr_path, os.path.join(curr_path, '../../'),
os.path.join(curr_path, 'compile'),
os.path.join(curr_path, '../compile'),
os.path.join(curr_path, '../../lib/')]
if os.name == 'nt':
dll_path.append(os.path.join(curr_path, './Release/'))
dll_path.append(os.path.join(curr_path, './windows/x64/DLL/'))
dll_path.append(os.path.join(curr_path, '../compile/Release/'))
dll_path.append(os.path.join(curr_path, '../compile/windows/x64/DLL/'))
dll_path.append(os.path.join(curr_path, '../../Release/'))
dll_path.append(os.path.join(curr_path, '../../windows/x64/DLL/'))
dll_path = [os.path.join(p, 'lib_lightgbm.dll') for p in dll_path]

Просмотреть файл

@ -33,7 +33,7 @@ def copy_files(use_gpu=False):
def copy_files_helper(folder_name):
src = os.path.join('..', folder_name)
if os.path.exists(src):
dst = os.path.join('./lightgbm', folder_name)
dst = os.path.join('./compile', folder_name)
shutil.rmtree(dst, ignore_errors=True)
distutils.dir_util.copy_tree(src, dst)
else:
@ -45,7 +45,7 @@ def copy_files(use_gpu=False):
copy_files_helper('windows')
if use_gpu:
copy_files_helper('compute')
distutils.file_util.copy_file("../CMakeLists.txt", "./lightgbm/")
distutils.file_util.copy_file("../CMakeLists.txt", "./compile/")
distutils.file_util.copy_file("../LICENSE", "./")
@ -80,7 +80,7 @@ def compile_cpp(use_mingw=False, use_gpu=False):
logger.info("Starting to compile the library.")
cmake_cmd = ["cmake", "../lightgbm/"]
cmake_cmd = ["cmake", "../compile/"]
if use_gpu:
cmake_cmd.append("-DUSE_GPU=ON")
if os.name == "nt":
@ -92,19 +92,19 @@ def compile_cpp(use_mingw=False, use_gpu=False):
error_msg='Please install MinGW first')
else:
status = 1
lib_path = "../lightgbm/windows/x64/DLL/lib_lightgbm.dll"
lib_path = "../compile/windows/x64/DLL/lib_lightgbm.dll"
if not use_gpu:
logger.info("Starting to compile with MSBuild from existing solution file.")
platform_toolsets = ("v141", "v140", "v120")
for pt in platform_toolsets:
status = silent_call(["MSBuild", "../lightgbm/windows/LightGBM.sln",
status = silent_call(["MSBuild", "../compile/windows/LightGBM.sln",
"/p:Configuration=DLL",
"/p:Platform=x64",
"/p:PlatformToolset={0}".format(pt)])
if status == 0 and os.path.exists(lib_path):
break
else:
clear_path("../lightgbm/windows/x64")
clear_path("../compile/windows/x64")
if status != 0 or not os.path.exists(lib_path):
logger.warning("Compilation with MSBuild from existing solution file failed.")
if status != 0 or not os.path.exists(lib_path):
@ -144,7 +144,7 @@ class CustomInstall(install):
user_options = install.user_options + [
('mingw', 'm', 'compile with mingw'),
('gpu', 'g', 'compile gpu version'),
('precompile', 'p', 'use precompile library')
('precompile', 'p', 'use precompiled library')
]
def initialize_options(self):
@ -167,6 +167,8 @@ class CustomSdist(sdist):
open("./_IS_SOURCE_PACKAGE.txt", 'w').close()
if os.path.exists("./lightgbm/Release/"):
shutil.rmtree('./lightgbm/Release/')
if os.path.exists("./lightgbm/windows/x64/"):
shutil.rmtree('./lightgbm/windows/x64/')
if os.path.isfile('./lightgbm/lib_lightgbm.so'):
os.remove('./lightgbm/lib_lightgbm.so')
sdist.run(self)
@ -180,9 +182,8 @@ if __name__ == "__main__":
dir_path = os.path.dirname(os.path.realpath(__file__))
if os.path.isfile(os.path.join('..', 'VERSION.txt')):
distutils.file_util.copy_file(
os.path.join('..', 'VERSION.txt'),
os.path.join('.', 'lightgbm'))
distutils.file_util.copy_file(os.path.join('..', 'VERSION.txt'),
os.path.join('.', 'lightgbm'))
version = open(os.path.join(dir_path, 'lightgbm', 'VERSION.txt')).read().strip()
sys.path.insert(0, '.')