-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][docs] update Python-package installation guide #6767
base: master
Are you sure you want to change the base?
Changes from all commits
1f6c773
dc765b0
339cc84
3e841e0
deb2d98
afdc323
e8f52a8
1f1d88f
b537c7e
fefaded
449292f
dd6e17a
9d93ca9
7141270
4ea935f
ce0b19e
eb8d2d3
c55af10
9d44d69
fb90500
6790bdd
8c58b4f
6f961d9
e271a29
b747e4d
80a7c20
8f6cb05
26c921a
e50acb5
8eb7005
0dd5983
d818fb8
4eaf198
ca2fee1
c09506a
ec9cd50
8148b69
acfe30d
8ed111f
02f4b95
ec24127
5f29431
6555396
d0fe127
ff3e4c7
73334ca
726ef96
a9a534c
848a536
784fcba
cc8a24e
03bd3c9
4cd32ce
19a07e2
e9cced7
ac34770
f7b8e7c
ddb52b9
b07feda
9d065ce
53b8e19
4b3c98a
e3a4836
d99d0cf
a592c54
df3f69d
dd710f5
3fc761f
3bee691
f160bcf
866b46f
e7c9a8e
b85cc0f
c9c5c04
dbc9400
00c31e3
88d586b
9ae9c28
9f056cf
2bd90f7
3f043dd
c9f8483
532121f
f4fc100
652ada1
b467e78
f722634
0a858fe
a212e1a
92db16e
7a80b77
078481d
08a98a3
fb27330
1e7e2ef
0d055ad
7a3ba7f
c13aa46
2a85784
0736db2
f0a541f
722f928
56cc500
da0ebc9
ace2590
c38187c
ed4c453
599561a
0247c6b
dd1a94a
1367902
bb39ff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -34,10 +34,14 @@ | |||||||
# OpenCL include directory. | ||||||||
# --opencl-library=FILEPATH | ||||||||
# Path to OpenCL library. | ||||||||
# --sanitizers=LIST_OF_SANITIZERS | ||||||||
# Semicolon separated list with chosen compiler sanitizers. | ||||||||
# --bit32 | ||||||||
# Compile 32-bit version. | ||||||||
# --cuda | ||||||||
# Compile CUDA version. | ||||||||
# --debug | ||||||||
# Compile in debug mode. | ||||||||
# --gpu | ||||||||
# Compile GPU version. | ||||||||
# --integrated-opencl | ||||||||
|
@@ -49,20 +53,22 @@ | |||||||
# --no-isolation | ||||||||
# Assume all build and install dependencies are already installed, | ||||||||
# don't go to the internet to get them. | ||||||||
# --nohomebrew | ||||||||
# Compile version ignoring Homebrew standard folders for finding dependencies. | ||||||||
# --nomp | ||||||||
# Compile version without OpenMP support. | ||||||||
# --precompile | ||||||||
# Use precompiled library. | ||||||||
# Only used with 'install' command. | ||||||||
# --time-costs | ||||||||
# Output time costs for different internal routines. | ||||||||
# Compile version that outputs time costs for different internal routines. | ||||||||
# --user | ||||||||
# Install into user-specific instead of global site-packages directory. | ||||||||
# Only used with 'install' command. | ||||||||
|
||||||||
set -e -u | ||||||||
|
||||||||
echo "building lightgbm" | ||||||||
echo "[INFO] building lightgbm" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the consistency with Line 141 in 60b0155
and to better distinguish between our own logs and scikit-build-core ones. |
||||||||
|
||||||||
# Default values of arguments | ||||||||
INSTALL="false" | ||||||||
|
@@ -132,27 +138,38 @@ while [ $# -gt 0 ]; do | |||||||
OPENCL_LIBRARY="${1#*=}" | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.OpenCL_LIBRARY='${OPENCL_LIBRARY}'" | ||||||||
;; | ||||||||
--sanitizers|--sanitizers=*) | ||||||||
if echo "$1" | grep -q '^*=*$'; | ||||||||
then shift; | ||||||||
fi | ||||||||
SANITIZERS="${1#*=}" | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_SANITIZER=ON" | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.ENABLED_SANITIZERS='${SANITIZERS}'" | ||||||||
;; | ||||||||
######### | ||||||||
# flags # | ||||||||
######### | ||||||||
--bit32) | ||||||||
export CMAKE_GENERATOR="Visual Studio 17 2022" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow to use any default Visual Studio version. |
||||||||
export CMAKE_GENERATOR_PLATFORM="Win32" | ||||||||
echo "[INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with generator '${CMAKE_GENERATOR}'." | ||||||||
echo "[INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with Visual Studio." | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.args=-AWin32" | ||||||||
;; | ||||||||
--cuda) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_CUDA=ON" | ||||||||
;; | ||||||||
--debug) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_DEBUG=ON" | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.build-type=Debug" | ||||||||
;; | ||||||||
--gpu) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_GPU=ON" | ||||||||
;; | ||||||||
--integrated-opencl) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.__INTEGRATE_OPENCL=ON" | ||||||||
;; | ||||||||
--mingw) | ||||||||
export CMAKE_GENERATOR='MinGW Makefiles' | ||||||||
# ref: https://stackoverflow.com/a/45104058/3986677 | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.CMAKE_SH=CMAKE_SH-NOTFOUND" | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.args=-G'MinGW Makefiles'" | ||||||||
;; | ||||||||
--mpi) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_MPI=ON" | ||||||||
|
@@ -161,6 +178,9 @@ while [ $# -gt 0 ]; do | |||||||
BUILD_ARGS="${BUILD_ARGS} --no-isolation" | ||||||||
PIP_INSTALL_ARGS="${PIP_INSTALL_ARGS} --no-build-isolation" | ||||||||
;; | ||||||||
--nohomebrew) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_HOMEBREW_FALLBACK=OFF" | ||||||||
;; | ||||||||
--nomp) | ||||||||
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_OPENMP=OFF" | ||||||||
;; | ||||||||
|
@@ -174,7 +194,7 @@ while [ $# -gt 0 ]; do | |||||||
PIP_INSTALL_ARGS="${PIP_INSTALL_ARGS} --user" | ||||||||
;; | ||||||||
*) | ||||||||
echo "invalid argument '${1}'" | ||||||||
echo "[ERROR] invalid argument '${1}'. Aborting" | ||||||||
exit 1 | ||||||||
;; | ||||||||
esac | ||||||||
|
@@ -315,18 +335,28 @@ if test "${INSTALL}" = true; then | |||||||
echo "" >> ./MANIFEST.in | ||||||||
mkdir -p ./lightgbm/lib | ||||||||
if test -f ../lib_lightgbm.so; then | ||||||||
echo "found pre-compiled lib_lightgbm.so" | ||||||||
echo "[INFO] found pre-compiled lib_lightgbm.so" | ||||||||
cp ../lib_lightgbm.so ./lightgbm/lib/lib_lightgbm.so | ||||||||
elif test -f ../lib_lightgbm.dylib; then | ||||||||
echo "found pre-compiled lib_lightgbm.dylib" | ||||||||
echo "[INFO] found pre-compiled lib_lightgbm.dylib" | ||||||||
cp ../lib_lightgbm.dylib ./lightgbm/lib/lib_lightgbm.dylib | ||||||||
elif test -f ../lib_lightgbm.dll; then | ||||||||
echo "[INFO] found pre-compiled lib_lightgbm.dll" | ||||||||
cp ../lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll | ||||||||
Comment on lines
+343
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be located there after compilation with MinGW: https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#mingw-w64 |
||||||||
elif test -f ../Release/lib_lightgbm.dll; then | ||||||||
echo "found pre-compiled Release/lib_lightgbm.dll" | ||||||||
echo "[INFO] found pre-compiled Release/lib_lightgbm.dll" | ||||||||
cp ../Release/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll | ||||||||
elif test -f ../windows/x64/DLL/lib_lightgbm.dll; then | ||||||||
echo "found pre-compiled windows/x64/DLL/lib_lightgbm.dll" | ||||||||
echo "[INFO] found pre-compiled windows/x64/DLL/lib_lightgbm.dll" | ||||||||
cp ../windows/x64/DLL/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll | ||||||||
cp ../windows/x64/DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib | ||||||||
elif test -f ../windows/x64/Debug_DLL/lib_lightgbm.dll; then | ||||||||
echo "[INFO] found pre-compiled windows/x64/Debug_DLL/lib_lightgbm.dll" | ||||||||
cp ../windows/x64/Debug_DLL/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll | ||||||||
cp ../windows/x64/Debug_DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib | ||||||||
Comment on lines
+353
to
+356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be located there after compilation with LightGBM/windows/LightGBM.vcxproj Lines 4 to 6 in 60b0155
|
||||||||
else | ||||||||
echo "[ERROR] cannot find pre-compiled library. Aborting" | ||||||||
exit 1 | ||||||||
Comment on lines
+357
to
+359
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this code, script simply builds empty sdist if no pre-compiled file was found. |
||||||||
fi | ||||||||
rm -f ./*.bak | ||||||||
else | ||||||||
|
@@ -336,29 +366,27 @@ if test "${INSTALL}" = true; then | |||||||
fi | ||||||||
|
||||||||
if test "${BUILD_SDIST}" = true; then | ||||||||
echo "--- building sdist ---" | ||||||||
echo "[INFO] --- building sdist ---" | ||||||||
rm -f ../dist/*.tar.gz | ||||||||
# shellcheck disable=SC2086 | ||||||||
python -m build \ | ||||||||
--sdist \ | ||||||||
--outdir ../dist \ | ||||||||
${BUILD_ARGS} \ | ||||||||
. | ||||||||
# use xargs to work with args that contain whitespaces | ||||||||
# note that empty echo string leads to that xargs doesn't run the command | ||||||||
# in some implementations of xargs | ||||||||
# ref: https://stackoverflow.com/a/8296746 | ||||||||
echo "--sdist --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build | ||||||||
Comment on lines
+371
to
+375
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use xargs to handle args with whitespaces, e.g. |
||||||||
fi | ||||||||
|
||||||||
if test "${BUILD_WHEEL}" = true; then | ||||||||
echo "--- building wheel ---" | ||||||||
echo "[INFO] --- building wheel ---" | ||||||||
rm -f ../dist/*.whl || true | ||||||||
# shellcheck disable=SC2086 | ||||||||
python -m build \ | ||||||||
--wheel \ | ||||||||
--outdir ../dist \ | ||||||||
${BUILD_ARGS} \ | ||||||||
. | ||||||||
# use xargs to work with args that contain whitespaces | ||||||||
# note that empty echo string leads to that xargs doesn't run the command | ||||||||
# in some implementations of xargs | ||||||||
# ref: https://stackoverflow.com/a/8296746 | ||||||||
echo "--wheel --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build | ||||||||
fi | ||||||||
|
||||||||
if test "${INSTALL}" = true; then | ||||||||
echo "--- installing lightgbm ---" | ||||||||
echo "[INFO] --- installing lightgbm ---" | ||||||||
cd ../dist | ||||||||
if test "${BUILD_WHEEL}" = true; then | ||||||||
PACKAGE_NAME="$(echo lightgbm*.whl)" | ||||||||
|
@@ -377,5 +405,5 @@ if test "${INSTALL}" = true; then | |||||||
cd ../ | ||||||||
fi | ||||||||
|
||||||||
echo "cleaning up" | ||||||||
echo "[INFO] cleaning up" | ||||||||
rm -rf ./lightgbm-python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missed options from https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst.