55
55
# Use precompiled library.
56
56
# Only used with 'install' command.
57
57
# --time-costs
58
- # Output time costs for different internal routines.
58
+ # Compile version that outputs time costs for different internal routines.
59
59
# --user
60
60
# Install into user-specific instead of global site-packages directory.
61
61
# Only used with 'install' command.
62
62
63
63
set -e -u
64
64
65
- echo " building lightgbm"
65
+ echo " [INFO] building lightgbm"
66
66
67
67
# Default values of arguments
68
68
INSTALL=" false"
@@ -136,9 +136,8 @@ while [ $# -gt 0 ]; do
136
136
# flags #
137
137
# ########
138
138
--bit32)
139
- export CMAKE_GENERATOR=" Visual Studio 17 2022"
140
- export CMAKE_GENERATOR_PLATFORM=" Win32"
141
- echo " [INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with generator '${CMAKE_GENERATOR} '."
139
+ echo " [INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with Visual Studio."
140
+ BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.args=-AWin32"
142
141
;;
143
142
--cuda)
144
143
BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.define.USE_CUDA=ON"
@@ -150,9 +149,9 @@ while [ $# -gt 0 ]; do
150
149
BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.define.__INTEGRATE_OPENCL=ON"
151
150
;;
152
151
--mingw)
153
- export CMAKE_GENERATOR=' MinGW Makefiles'
154
152
# ref: https://stackoverflow.com/a/45104058/3986677
155
153
BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.define.CMAKE_SH=CMAKE_SH-NOTFOUND"
154
+ BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.args=-G'MinGW Makefiles'"
156
155
;;
157
156
--mpi)
158
157
BUILD_ARGS=" ${BUILD_ARGS} --config-setting=cmake.define.USE_MPI=ON"
@@ -174,7 +173,7 @@ while [ $# -gt 0 ]; do
174
173
PIP_INSTALL_ARGS=" ${PIP_INSTALL_ARGS} --user"
175
174
;;
176
175
* )
177
- echo " invalid argument '${1} '"
176
+ echo " [ERROR] invalid argument '${1} '. Aborting "
178
177
exit 1
179
178
;;
180
179
esac
@@ -315,18 +314,28 @@ if test "${INSTALL}" = true; then
315
314
echo " " >> ./MANIFEST.in
316
315
mkdir -p ./lightgbm/lib
317
316
if test -f ../lib_lightgbm.so; then
318
- echo " found pre-compiled lib_lightgbm.so"
317
+ echo " [INFO] found pre-compiled lib_lightgbm.so"
319
318
cp ../lib_lightgbm.so ./lightgbm/lib/lib_lightgbm.so
320
319
elif test -f ../lib_lightgbm.dylib; then
321
- echo " found pre-compiled lib_lightgbm.dylib"
320
+ echo " [INFO] found pre-compiled lib_lightgbm.dylib"
322
321
cp ../lib_lightgbm.dylib ./lightgbm/lib/lib_lightgbm.dylib
322
+ elif test -f ../lib_lightgbm.dll; then
323
+ echo " [INFO] found pre-compiled lib_lightgbm.dll"
324
+ cp ../lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
323
325
elif test -f ../Release/lib_lightgbm.dll; then
324
- echo " found pre-compiled Release/lib_lightgbm.dll"
326
+ echo " [INFO] found pre-compiled Release/lib_lightgbm.dll"
325
327
cp ../Release/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
326
328
elif test -f ../windows/x64/DLL/lib_lightgbm.dll; then
327
- echo " found pre-compiled windows/x64/DLL/lib_lightgbm.dll"
329
+ echo " [INFO] found pre-compiled windows/x64/DLL/lib_lightgbm.dll"
328
330
cp ../windows/x64/DLL/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
329
331
cp ../windows/x64/DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib
332
+ elif test -f ../windows/x64/Debug_DLL/lib_lightgbm.dll; then
333
+ echo " [INFO] found pre-compiled windows/x64/Debug_DLL/lib_lightgbm.dll"
334
+ cp ../windows/x64/Debug_DLL/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
335
+ cp ../windows/x64/Debug_DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib
336
+ else
337
+ echo " [ERROR] cannot find pre-compiled library. Aborting"
338
+ exit 1
330
339
fi
331
340
rm -f ./* .bak
332
341
else
@@ -336,29 +345,27 @@ if test "${INSTALL}" = true; then
336
345
fi
337
346
338
347
if test " ${BUILD_SDIST} " = true ; then
339
- echo " --- building sdist ---"
348
+ echo " [INFO] --- building sdist ---"
340
349
rm -f ../dist/* .tar.gz
341
- # shellcheck disable=SC2086
342
- python -m build \
343
- --sdist \
344
- --outdir ../dist \
345
- ${BUILD_ARGS} \
346
- .
350
+ # use xargs to work with args that contain whitespaces
351
+ # note that empty echo string leads to that xargs doesn't run the command
352
+ # in some implementations of xargs
353
+ # ref: https://stackoverflow.com/a/8296746
354
+ echo " --sdist --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build
347
355
fi
348
356
349
357
if test " ${BUILD_WHEEL} " = true ; then
350
- echo " --- building wheel ---"
358
+ echo " [INFO] --- building wheel ---"
351
359
rm -f ../dist/* .whl || true
352
- # shellcheck disable=SC2086
353
- python -m build \
354
- --wheel \
355
- --outdir ../dist \
356
- ${BUILD_ARGS} \
357
- .
360
+ # use xargs to work with args that contain whitespaces
361
+ # note that empty echo string leads to that xargs doesn't run the command
362
+ # in some implementations of xargs
363
+ # ref: https://stackoverflow.com/a/8296746
364
+ echo " --wheel --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build
358
365
fi
359
366
360
367
if test " ${INSTALL} " = true ; then
361
- echo " --- installing lightgbm ---"
368
+ echo " [INFO] --- installing lightgbm ---"
362
369
cd ../dist
363
370
if test " ${BUILD_WHEEL} " = true ; then
364
371
PACKAGE_NAME=" $( echo lightgbm* .whl) "
@@ -377,5 +384,5 @@ if test "${INSTALL}" = true; then
377
384
cd ../
378
385
fi
379
386
380
- echo " cleaning up"
387
+ echo " [INFO] cleaning up"
381
388
rm -rf ./lightgbm-python
0 commit comments