add platform if statement in setup.py for pip for pull #450 issuecomment-133795287

This commit is contained in:
phunterlau 2015-08-23 20:38:26 -07:00
parent 5e81a210ce
commit f258a68029
3 changed files with 17 additions and 7 deletions

View File

@ -5,13 +5,14 @@ Installation
We are on [PyPI](https://pypi.python.org/pypi/xgboost) now. For stable version, please install using pip: We are on [PyPI](https://pypi.python.org/pypi/xgboost) now. For stable version, please install using pip:
* ```pip install xgboost``` * ```pip install xgboost```
* Note for windows users: this pip installation may not work on some windows environment. Please install from github if pip doesn't work on windows. * Note for windows users: this pip installation may not work on some windows environment, and it may cause unexpected errors. pip installation on windows is currently disabled for further invesigation, please install from github.
For up-to-date version, please install from github. For up-to-date version, please install from github.
* To make the python module, type ```./build.sh``` in the root directory of project * To make the python module, type ```./build.sh``` in the root directory of project
* Make sure you have [setuptools](https://pypi.python.org/pypi/setuptools) * Make sure you have [setuptools](https://pypi.python.org/pypi/setuptools)
* Install with `python setup.py install` from this directory. * Install with `python setup.py install` from this directory.
* For windows users, please use the Visual Studio project file under [windows folder](../windows/). See also the [installation tutorial](https://www.kaggle.com/c/otto-group-product-classification-challenge/forums/t/13043/run-xgboost-from-windows-and-python) from Kaggle Otto Forum.
Examples Examples
------ ------

View File

@ -5,12 +5,17 @@ import sys
from setuptools import setup, find_packages from setuptools import setup, find_packages
import subprocess import subprocess
sys.path.insert(0, '.') sys.path.insert(0, '.')
#build on the fly
build_sh = subprocess.Popen(['sh', 'xgboost/build-python.sh']) import os
build_sh.wait() #build on the fly if install in pip
output = build_sh.communicate() #otherwise, use build.sh in the parent directory
print output
if 'pip' in __file__:
if not os.name == 'nt': #if not windows
build_sh = subprocess.Popen(['sh', 'xgboost/build-python.sh'])
build_sh.wait()
output = build_sh.communicate()
print output
import xgboost import xgboost
@ -23,7 +28,7 @@ LIB_PATH = xgboost.core.find_lib_path()
#and be sure to test it firstly using "python setup.py register sdist upload -r pypitest" #and be sure to test it firstly using "python setup.py register sdist upload -r pypitest"
setup(name='xgboost', setup(name='xgboost',
version=xgboost.__version__, version=xgboost.__version__,
#version='0.4a12', #version='0.4a13',
description=xgboost.__doc__, description=xgboost.__doc__,
install_requires=[ install_requires=[
'numpy', 'numpy',

View File

@ -45,8 +45,12 @@ def find_lib_path():
if os.name == 'nt': if os.name == 'nt':
if platform.architecture()[0] == '64bit': if platform.architecture()[0] == '64bit':
dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/')) dll_path.append(os.path.join(curr_path, '../../windows/x64/Release/'))
#hack for pip installation when copy all parent source directory here
dll_path.append(os.path.join(curr_path, './windows/x64/Release/'))
else: else:
dll_path.append(os.path.join(curr_path, '../../windows/Release/')) dll_path.append(os.path.join(curr_path, '../../windows/Release/'))
#hack for pip installation when copy all parent source directory here
dll_path.append(os.path.join(curr_path, './windows/Release/'))
if os.name == 'nt': if os.name == 'nt':
dll_path = [os.path.join(p, 'xgboost_wrapper.dll') for p in dll_path] dll_path = [os.path.join(p, 'xgboost_wrapper.dll') for p in dll_path]
else: else: