summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: eec9dd669328dc9f0d400e9744059342fc3dd4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Maintainer:  jyantis <yantis@yantis.net>

# R package isn't compiling anymore so temp removed.

pkgbase=xgboost-git
pkgname=('xgboost-git'
         'python-xgboost-git'
         'python2-xgboost-git'
         )
         # 'r-xgboost-git'
pkgver=r1639.00a8076
pkgrel=2
url='https://github.com/tqchen/xgboost'
license=('APACHE')
source=('git+https://github.com/tqchen/xgboost.git')
sha256sums=('SKIP')
makedepends=('git')
arch=('x86_64')
pkgver() {
  cd xgboost
  set -o pipefail
  git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g' ||
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package_xgboost-git() {
  pkgdesc='An optimized general purpose gradient boosting library. Which is parallelized using OpenMP. It implements machine learning algorithm under gradient boosting framework, including generalized linear model and gradient boosted regression tree'
  provides=('xgboost')
  conflicts=('xgboost')
  depends=('python' 'bash')
  optdepends=('python-xgboost-git: Python 3 Wrapper'
              'python2-xgboost-git: Python 2 Wrapper')
              # 'r-xgboost-git: R Wrapper'

  cd xgboost
  make

  # Install License
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # Install Documentation
  install -D -m644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"

  # Install main executable
  install -Dm755 "xgboost" "$pkgdir/usr/bin/xgboost"

  # Install shared libraries
  mkdir -p $pkgdir/usr/lib/
  install -Dm644 wrapper/*.so "${pkgdir}/usr/lib/"

  mkdir -p $pkgdir/opt/xgboost

  # Copy the python wrapper to opt/xgboost
  cp -r wrapper $pkgdir/opt/xgboost

  # Copy the demos to opt/xgboost
  cp -r demo $pkgdir/opt/xgboost
}

# package_r-xgboost-git() {
#   msg "You will need to have these R packages installed to use this"
#   msg "Type this in R:"
#   msg "install.packages(\"data.table\", repos=\"http://cran.rstudio.com/\")"
#   msg "install.packages(\"magrittr\", repos=\"http://cran.rstudio.com/\")"
#   msg "install.packages(\"DiagrammeR\", repos=\"http://cran.rstudio.com/\")"
#   msg "install.packages(\"vcd\", repos=\"http://cran.rstudio.com/\")"

#   pkgdesc="XGBoost R wrapper"
#   depends=('xgboost' 'r')
#   conflicts=('r-xgboost')
#   provides=('r-xgboost')
#   makedepends=('xgboost')

#   cd xgboost

#   # Hotpatch Error: T used instead of TRUE
#   for file in $(find . -name '*.R' -print); do
#     sed -i 's/ = T)/ = TRUE)/' $file
#   done

#   for file in $(find . -name '*.Rd' -print); do
#     sed -i 's/ = T)/ = TRUE)/' $file
#   done

#   make clean
#   rm -rf xgboost xgboost*.tar.gz
#   cp -r R-package xgboost
#   rm -rf xgboost/inst/examples/*.buffer
#   rm -rf xgboost/inst/examples/*.model
#   rm -rf xgboost/inst/examples/dump*
#   rm -rf xgboost/src/*.o xgboost/src/*.so xgboost/src/*.dll
#   rm -rf xgboost/demo/*.model xgboost/demo/*.buffer xgboost/demo/*.txt
#   rm -rf xgboost/demo/runall.R
#   cp -r src xgboost/src/src
#   mkdir xgboost/src/wrapper
#   cp  wrapper/xgboost_wrapper.h xgboost/src/wrapper
#   cp  wrapper/xgboost_wrapper.cpp xgboost/src/wrapper
#   cp ./LICENSE xgboost
#   cat R-package/src/Makevars|sed '2s/.*/PKGROOT=./' > xgboost/src/Makevars
#   cat R-package/src/Makevars.win|sed '2s/.*/PKGROOT=./' > xgboost/src/Makevars.win
#   R CMD build xgboost
#   rm -rf xgboost
#   R CMD INSTALL --as-cran xgboost*.tar.gz
# }

package_python2-xgboost-git() {
  pkgdesc="XGBoost Python 2 wrapper"
  depends=('xgboost'
           'python2'
           'python2-numpy'
           'python2-scipy'
           'python2-setuptools'
           'bash')
  conflicts=('python2-xgboost')
  provides=('python2-xgboost')
  makedepends=('xgboost')

  cd xgboost

  msg "Patching any #!/usr/bin/python to #!/usr/bin/python2"
  for file in $(find . -name '*.py' -print); do
    sed -r -i 's_^#!.*/usr/bin/python(\s|$)_#!/usr/bin/python2_' $file
    sed -r -i 's_^#!.*/usr/bin/env(\s)*python(\s|$)_#!/usr/bin/env python2_' $file
  done

  msg "Patching it so it can find the shared library"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/os.path.dirname(__file__)/"\/usr\/lib" /' $file
  done

  msg "Patching out the sys path usage since we don't use it anymore"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/sys.path.append/# sys.path.append/' $file
  done

  msg "Patching in our module"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/import xgboost/from xgboost import xgboost/' $file
  done

  msg "Since no setup.py lets set it up by hand"
  pydir=`python2 -c "from distutils.sysconfig import get_python_lib; \
    print get_python_lib()"`
  mkdir -p "${pkgdir}/${pydir}"
  mkdir -p "${pkgdir}/${pydir}/xgboost"
  touch "${pkgdir}/${pydir}/xgboost/__init__.py"

  cp wrapper/xgboost.py "${pkgdir}/${pydir}/xgboost"
  cp -R demo "${pkgdir}/${pydir}/xgboost"
}

package_python-xgboost-git() {
  pkgdesc="XGBoost Python 3 wrapper"
  depends=('xgboost'
           'python'
           'python-numpy'
           'python-scipy'
           'python-setuptools'
           'bash')
  conflicts=('python-xgboost')
  provides=('python-xgboost')
  makedepends=('xgboost')

  cd xgboost

  msg "Patching it so it can find the shared library"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/os.path.dirname(__file__)/"\/usr\/lib" /' $file
  done

  msg "Patching out the sys path usage since we don't use it anymore"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/sys.path.append/# sys.path.append/' $file
  done

  msg "Patching in our module"
  for file in $(find . -name '*.py' -print); do
    sed -i 's/import xgboost/from xgboost import xgboost/' $file
  done

  msg "Since no setup.py lets set it up by hand"
  pydir=`python -c "from distutils.sysconfig import get_python_lib; \
    print(get_python_lib())"`
  mkdir -p "${pkgdir}/${pydir}"
  mkdir -p "${pkgdir}/${pydir}/xgboost"
  touch "${pkgdir}/${pydir}/xgboost/__init__.py"

  cp wrapper/xgboost.py "${pkgdir}/${pydir}/xgboost"
  cp -R demo "${pkgdir}/${pydir}/xgboost"
}

# vim:set ts=2 sw=2 et: