Commit 9eab7ec8 authored by Nikita Titov's avatar Nikita Titov Committed by Guolin Ke
Browse files

[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
parent 8984111f
...@@ -2,6 +2,9 @@ language: cpp ...@@ -2,6 +2,9 @@ language: cpp
sudo: required sudo: required
dist: trusty dist: trusty
git:
submodules: true
compiler: compiler:
- gcc - gcc
...@@ -10,15 +13,17 @@ os: ...@@ -10,15 +13,17 @@ os:
- osx - osx
env: env:
global:
- PYTHON_VERSION=3.6
matrix: matrix:
- TASK=regular PYTHON_VERSION=3.6 - TASK=regular
- TASK=mpi PYTHON_VERSION=3.6 - TASK=mpi
- TASK=pylint PYTHON_VERSION=3.6 - TASK=pylint
- TASK=if-else PYTHON_VERSION=3.6 - TASK=if-else
- TASK=sdist PYTHON_VERSION=3.6 - TASK=sdist
- TASK=bdist PYTHON_VERSION=3.6 - TASK=bdist
- TASK=gpu METHOD=source PYTHON_VERSION=3.6 - TASK=gpu METHOD=source
- TASK=gpu METHOD=pip PYTHON_VERSION=3.6 - TASK=gpu METHOD=pip
- TASK=regular PYTHON_VERSION=2.7 - TASK=regular PYTHON_VERSION=2.7
- TASK=regular PYTHON_VERSION=3.4 - TASK=regular PYTHON_VERSION=3.4
- TASK=regular PYTHON_VERSION=3.5 - TASK=regular PYTHON_VERSION=3.5
...@@ -26,11 +31,11 @@ env: ...@@ -26,11 +31,11 @@ env:
matrix: matrix:
exclude: exclude:
- os: osx - os: osx
env: TASK=gpu METHOD=source PYTHON_VERSION=3.6 env: TASK=gpu METHOD=source
- os: osx - os: osx
env: TASK=gpu METHOD=pip PYTHON_VERSION=3.6 env: TASK=gpu METHOD=pip
- os: osx - os: osx
env: TASK=pylint PYTHON_VERSION=3.6 env: TASK=pylint
before_install: before_install:
- test -n $CC && unset CC - test -n $CC && unset CC
......
...@@ -14,6 +14,7 @@ environment: ...@@ -14,6 +14,7 @@ environment:
clone_depth: 50 clone_depth: 50
install: 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=%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 PATH=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
- set PYTHON_VERSION=%CONFIGURATION% - set PYTHON_VERSION=%CONFIGURATION%
......
...@@ -2,9 +2,11 @@ prune build ...@@ -2,9 +2,11 @@ prune build
include LICENSE include LICENSE
include *.rst *.txt include *.rst *.txt
recursive-include lightgbm *.py *.txt *.so recursive-include lightgbm *.py *.txt *.so
recursive-include lightgbm/Release *.dll recursive-include compile *.txt *.so
recursive-include lightgbm/include * recursive-include compile/Release *.dll
recursive-include lightgbm/src * recursive-include compile/compute *
recursive-include lightgbm/windows LightGBM.sln LightGBM.vcxproj LightGBM.vcxproj.filters recursive-include compile/include *
recursive-include lightgbm/windows/x64/DLL *.dll 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] global-exclude *.py[co]
...@@ -16,10 +16,13 @@ def find_lib_path(): ...@@ -16,10 +16,13 @@ def find_lib_path():
return [] return []
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) 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': if os.name == 'nt':
dll_path.append(os.path.join(curr_path, './Release/')) dll_path.append(os.path.join(curr_path, '../compile/Release/'))
dll_path.append(os.path.join(curr_path, './windows/x64/DLL/')) 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, '../../Release/'))
dll_path.append(os.path.join(curr_path, '../../windows/x64/DLL/')) 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] dll_path = [os.path.join(p, 'lib_lightgbm.dll') for p in dll_path]
......
...@@ -33,7 +33,7 @@ def copy_files(use_gpu=False): ...@@ -33,7 +33,7 @@ def copy_files(use_gpu=False):
def copy_files_helper(folder_name): def copy_files_helper(folder_name):
src = os.path.join('..', folder_name) src = os.path.join('..', folder_name)
if os.path.exists(src): 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) shutil.rmtree(dst, ignore_errors=True)
distutils.dir_util.copy_tree(src, dst) distutils.dir_util.copy_tree(src, dst)
else: else:
...@@ -45,7 +45,7 @@ def copy_files(use_gpu=False): ...@@ -45,7 +45,7 @@ def copy_files(use_gpu=False):
copy_files_helper('windows') copy_files_helper('windows')
if use_gpu: if use_gpu:
copy_files_helper('compute') 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", "./") distutils.file_util.copy_file("../LICENSE", "./")
...@@ -80,7 +80,7 @@ def compile_cpp(use_mingw=False, use_gpu=False): ...@@ -80,7 +80,7 @@ def compile_cpp(use_mingw=False, use_gpu=False):
logger.info("Starting to compile the library.") logger.info("Starting to compile the library.")
cmake_cmd = ["cmake", "../lightgbm/"] cmake_cmd = ["cmake", "../compile/"]
if use_gpu: if use_gpu:
cmake_cmd.append("-DUSE_GPU=ON") cmake_cmd.append("-DUSE_GPU=ON")
if os.name == "nt": if os.name == "nt":
...@@ -92,19 +92,19 @@ def compile_cpp(use_mingw=False, use_gpu=False): ...@@ -92,19 +92,19 @@ def compile_cpp(use_mingw=False, use_gpu=False):
error_msg='Please install MinGW first') error_msg='Please install MinGW first')
else: else:
status = 1 status = 1
lib_path = "../lightgbm/windows/x64/DLL/lib_lightgbm.dll" lib_path = "../compile/windows/x64/DLL/lib_lightgbm.dll"
if not use_gpu: if not use_gpu:
logger.info("Starting to compile with MSBuild from existing solution file.") logger.info("Starting to compile with MSBuild from existing solution file.")
platform_toolsets = ("v141", "v140", "v120") platform_toolsets = ("v141", "v140", "v120")
for pt in platform_toolsets: 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:Configuration=DLL",
"/p:Platform=x64", "/p:Platform=x64",
"/p:PlatformToolset={0}".format(pt)]) "/p:PlatformToolset={0}".format(pt)])
if status == 0 and os.path.exists(lib_path): if status == 0 and os.path.exists(lib_path):
break break
else: else:
clear_path("../lightgbm/windows/x64") clear_path("../compile/windows/x64")
if status != 0 or not os.path.exists(lib_path): if status != 0 or not os.path.exists(lib_path):
logger.warning("Compilation with MSBuild from existing solution file failed.") logger.warning("Compilation with MSBuild from existing solution file failed.")
if status != 0 or not os.path.exists(lib_path): if status != 0 or not os.path.exists(lib_path):
...@@ -144,7 +144,7 @@ class CustomInstall(install): ...@@ -144,7 +144,7 @@ class CustomInstall(install):
user_options = install.user_options + [ user_options = install.user_options + [
('mingw', 'm', 'compile with mingw'), ('mingw', 'm', 'compile with mingw'),
('gpu', 'g', 'compile gpu version'), ('gpu', 'g', 'compile gpu version'),
('precompile', 'p', 'use precompile library') ('precompile', 'p', 'use precompiled library')
] ]
def initialize_options(self): def initialize_options(self):
...@@ -167,6 +167,8 @@ class CustomSdist(sdist): ...@@ -167,6 +167,8 @@ class CustomSdist(sdist):
open("./_IS_SOURCE_PACKAGE.txt", 'w').close() open("./_IS_SOURCE_PACKAGE.txt", 'w').close()
if os.path.exists("./lightgbm/Release/"): if os.path.exists("./lightgbm/Release/"):
shutil.rmtree('./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'): if os.path.isfile('./lightgbm/lib_lightgbm.so'):
os.remove('./lightgbm/lib_lightgbm.so') os.remove('./lightgbm/lib_lightgbm.so')
sdist.run(self) sdist.run(self)
...@@ -180,8 +182,7 @@ if __name__ == "__main__": ...@@ -180,8 +182,7 @@ if __name__ == "__main__":
dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = os.path.dirname(os.path.realpath(__file__))
if os.path.isfile(os.path.join('..', 'VERSION.txt')): if os.path.isfile(os.path.join('..', 'VERSION.txt')):
distutils.file_util.copy_file( distutils.file_util.copy_file(os.path.join('..', 'VERSION.txt'),
os.path.join('..', 'VERSION.txt'),
os.path.join('.', 'lightgbm')) os.path.join('.', 'lightgbm'))
version = open(os.path.join(dir_path, 'lightgbm', 'VERSION.txt')).read().strip() version = open(os.path.join(dir_path, 'lightgbm', 'VERSION.txt')).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