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:
* ```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.
* 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)
* 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
------

View File

@ -5,12 +5,17 @@ import sys
from setuptools import setup, find_packages
import subprocess
sys.path.insert(0, '.')
#build on the fly
build_sh = subprocess.Popen(['sh', 'xgboost/build-python.sh'])
build_sh.wait()
output = build_sh.communicate()
print output
import os
#build on the fly if install in pip
#otherwise, use build.sh in the parent directory
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
@ -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"
setup(name='xgboost',
version=xgboost.__version__,
#version='0.4a12',
#version='0.4a13',
description=xgboost.__doc__,
install_requires=[
'numpy',

View File

@ -45,8 +45,12 @@ def find_lib_path():
if os.name == 'nt':
if platform.architecture()[0] == '64bit':
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:
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':
dll_path = [os.path.join(p, 'xgboost_wrapper.dll') for p in dll_path]
else: