Unverified Commit d18fff10 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[docs] update Python-package installation guide (#6767)



* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update LightGBM.vcxproj

* Update LightGBM.vcxproj

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* no more than one sentence per one line

* address review comments

* address review comments

---------
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>
parent 5aaaec8e
...@@ -55,14 +55,14 @@ ...@@ -55,14 +55,14 @@
# Use precompiled library. # Use precompiled library.
# Only used with 'install' command. # Only used with 'install' command.
# --time-costs # --time-costs
# Output time costs for different internal routines. # Compile version that outputs time costs for different internal routines.
# --user # --user
# Install into user-specific instead of global site-packages directory. # Install into user-specific instead of global site-packages directory.
# Only used with 'install' command. # Only used with 'install' command.
set -e -u set -e -u
echo "building lightgbm" echo "[INFO] building lightgbm"
# Default values of arguments # Default values of arguments
INSTALL="false" INSTALL="false"
...@@ -136,9 +136,8 @@ while [ $# -gt 0 ]; do ...@@ -136,9 +136,8 @@ while [ $# -gt 0 ]; do
# flags # # flags #
######### #########
--bit32) --bit32)
export CMAKE_GENERATOR="Visual Studio 17 2022" echo "[INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with Visual Studio."
export CMAKE_GENERATOR_PLATFORM="Win32" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.args=-AWin32"
echo "[INFO] Attempting to build 32-bit version of LightGBM, which is only supported on Windows with generator '${CMAKE_GENERATOR}'."
;; ;;
--cuda) --cuda)
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_CUDA=ON" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_CUDA=ON"
...@@ -150,9 +149,9 @@ while [ $# -gt 0 ]; do ...@@ -150,9 +149,9 @@ while [ $# -gt 0 ]; do
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.__INTEGRATE_OPENCL=ON" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.__INTEGRATE_OPENCL=ON"
;; ;;
--mingw) --mingw)
export CMAKE_GENERATOR='MinGW Makefiles'
# ref: https://stackoverflow.com/a/45104058/3986677 # 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.define.CMAKE_SH=CMAKE_SH-NOTFOUND"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.args=-G'MinGW Makefiles'"
;; ;;
--mpi) --mpi)
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_MPI=ON" BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_MPI=ON"
...@@ -174,7 +173,7 @@ while [ $# -gt 0 ]; do ...@@ -174,7 +173,7 @@ while [ $# -gt 0 ]; do
PIP_INSTALL_ARGS="${PIP_INSTALL_ARGS} --user" PIP_INSTALL_ARGS="${PIP_INSTALL_ARGS} --user"
;; ;;
*) *)
echo "invalid argument '${1}'" echo "[ERROR] invalid argument '${1}'. Aborting"
exit 1 exit 1
;; ;;
esac esac
...@@ -315,18 +314,28 @@ if test "${INSTALL}" = true; then ...@@ -315,18 +314,28 @@ if test "${INSTALL}" = true; then
echo "" >> ./MANIFEST.in echo "" >> ./MANIFEST.in
mkdir -p ./lightgbm/lib mkdir -p ./lightgbm/lib
if test -f ../lib_lightgbm.so; then 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 cp ../lib_lightgbm.so ./lightgbm/lib/lib_lightgbm.so
elif test -f ../lib_lightgbm.dylib; then 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 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
elif test -f ../Release/lib_lightgbm.dll; then 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 cp ../Release/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
elif test -f ../windows/x64/DLL/lib_lightgbm.dll; then 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.dll ./lightgbm/lib/lib_lightgbm.dll
cp ../windows/x64/DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib 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
else
echo "[ERROR] cannot find pre-compiled library. Aborting"
exit 1
fi fi
rm -f ./*.bak rm -f ./*.bak
else else
...@@ -336,29 +345,27 @@ if test "${INSTALL}" = true; then ...@@ -336,29 +345,27 @@ if test "${INSTALL}" = true; then
fi fi
if test "${BUILD_SDIST}" = true; then if test "${BUILD_SDIST}" = true; then
echo "--- building sdist ---" echo "[INFO] --- building sdist ---"
rm -f ../dist/*.tar.gz rm -f ../dist/*.tar.gz
# shellcheck disable=SC2086 # use xargs to work with args that contain whitespaces
python -m build \ # note that empty echo string leads to that xargs doesn't run the command
--sdist \ # in some implementations of xargs
--outdir ../dist \ # ref: https://stackoverflow.com/a/8296746
${BUILD_ARGS} \ echo "--sdist --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build
.
fi fi
if test "${BUILD_WHEEL}" = true; then if test "${BUILD_WHEEL}" = true; then
echo "--- building wheel ---" echo "[INFO] --- building wheel ---"
rm -f ../dist/*.whl || true rm -f ../dist/*.whl || true
# shellcheck disable=SC2086 # use xargs to work with args that contain whitespaces
python -m build \ # note that empty echo string leads to that xargs doesn't run the command
--wheel \ # in some implementations of xargs
--outdir ../dist \ # ref: https://stackoverflow.com/a/8296746
${BUILD_ARGS} \ echo "--wheel --outdir ../dist ${BUILD_ARGS} ." | xargs python -m build
.
fi fi
if test "${INSTALL}" = true; then if test "${INSTALL}" = true; then
echo "--- installing lightgbm ---" echo "[INFO] --- installing lightgbm ---"
cd ../dist cd ../dist
if test "${BUILD_WHEEL}" = true; then if test "${BUILD_WHEEL}" = true; then
PACKAGE_NAME="$(echo lightgbm*.whl)" PACKAGE_NAME="$(echo lightgbm*.whl)"
...@@ -377,5 +384,5 @@ if test "${INSTALL}" = true; then ...@@ -377,5 +384,5 @@ if test "${INSTALL}" = true; then
cd ../ cd ../
fi fi
echo "cleaning up" echo "[INFO] cleaning up"
rm -rf ./lightgbm-python rm -rf ./lightgbm-python
This diff is collapsed.
...@@ -45,6 +45,10 @@ dask = [ ...@@ -45,6 +45,10 @@ dask = [
pandas = [ pandas = [
"pandas>=0.24.0" "pandas>=0.24.0"
] ]
plotting = [
"graphviz",
"matplotlib"
]
scikit-learn = [ scikit-learn = [
"scikit-learn>=0.24.2" "scikit-learn>=0.24.2"
] ]
...@@ -63,15 +67,9 @@ build-backend = "scikit_build_core.build" ...@@ -63,15 +67,9 @@ build-backend = "scikit_build_core.build"
# based on https://github.com/scikit-build/scikit-build-core#configuration # based on https://github.com/scikit-build/scikit-build-core#configuration
[tool.scikit-build] [tool.scikit-build]
cmake.version = "CMakeLists.txt"
ninja.version = ">=1.11" ninja.version = ">=1.11"
ninja.make-fallback = true ninja.make-fallback = true
cmake.args = [
"-D__BUILD_FOR_PYTHON:BOOL=ON"
]
build.verbose = false build.verbose = false
cmake.build-type = "Release"
build.targets = ["_lightgbm"] build.targets = ["_lightgbm"]
install.strip = true install.strip = true
logging.level = "INFO" logging.level = "INFO"
...@@ -81,6 +79,13 @@ experimental = false ...@@ -81,6 +79,13 @@ experimental = false
strict-config = false strict-config = false
minimum-version = "build-system.requires" minimum-version = "build-system.requires"
[tool.scikit-build.cmake]
version = "CMakeLists.txt"
build-type = "Release"
[tool.scikit-build.cmake.define]
__BUILD_FOR_PYTHON = "ON"
# end:build-system # end:build-system
[tool.mypy] [tool.mypy]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment