Skip to content
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

[python-package] [ci] switch to PEP 517 / 518 builds (remove setup.py) (fixes #5061) #5759

Merged
merged 110 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
b376e1e
got compilation basically working
jameslamb Feb 12, 2023
2bda465
MANIFEST.in
jameslamb Feb 12, 2023
f810685
merge master
jameslamb Feb 18, 2023
2ed9696
MAC WHEEL WORKING :)
jameslamb Feb 18, 2023
5783a33
(macOS wheel working) remove unnecessary MANIFEST.in stuff
jameslamb Feb 18, 2023
cb1ee48
(macOS wheel, sdist working) add test scripts
jameslamb Feb 20, 2023
833548f
(macOS wheel, sdist working) make it possible to just build sdist or …
jameslamb Feb 20, 2023
b170cd3
(macOS wheel, sdist working) remove unnecessary comments
jameslamb Feb 20, 2023
39aed07
start converting CI scripts
jameslamb Feb 21, 2023
f3713b3
fix paths
jameslamb Feb 21, 2023
133ef86
install build
jameslamb Feb 21, 2023
cee55f6
update TODO
jameslamb Feb 21, 2023
23e706d
Merge branch 'master' into wip-python-static-metadata
jameslamb Mar 1, 2023
27c2fad
Merge branch 'master' into python-static-metadata
jameslamb Mar 1, 2023
23bbb78
(macOS wheel, sdist working) add commands to script
jameslamb Mar 1, 2023
cd0dc46
add more options
jameslamb Mar 1, 2023
4e1cf4c
start testing in CI
jameslamb Mar 1, 2023
985c5b1
remove R jobs
jameslamb Mar 1, 2023
571ae69
fix version
jameslamb Mar 1, 2023
52c4cab
semicolons
jameslamb Mar 1, 2023
78d0019
modify paths
jameslamb Mar 1, 2023
7acff39
fix libpath paths
jameslamb Mar 2, 2023
ed4fc0d
test python first
jameslamb Mar 2, 2023
ccdf765
no -o pipefail
jameslamb Mar 3, 2023
ffa036f
more script changes
jameslamb Mar 3, 2023
6d9eaac
(broken) trying to implement --precompile
jameslamb Mar 3, 2023
3c48b9d
fix library-loading in C API test
jameslamb Mar 7, 2023
296e3a6
merge master
jameslamb Mar 7, 2023
cd22dc4
remove R CI
jameslamb Mar 7, 2023
eacd069
add --precompile and fix paths
jameslamb Mar 7, 2023
007bca5
add --user and fix distro path
jameslamb Mar 7, 2023
93b6a58
skip one appveyor job
jameslamb Mar 8, 2023
4cbe3dc
Merge branch 'master' into python-static-metadata
jameslamb Mar 8, 2023
7b948a9
check for files
jameslamb Mar 8, 2023
55a0b5b
get logs
jameslamb Mar 8, 2023
d19e72a
fix version for --precompile
jameslamb Mar 8, 2023
0ee9063
set all DESTINATION
jameslamb Mar 8, 2023
9ce5848
add sh.exe back to PATH
jameslamb Mar 8, 2023
6da577d
test MinGW
jameslamb Mar 10, 2023
d67b359
merge master
jameslamb Apr 2, 2023
8c0d209
[ci] replace setup.py with a shell script
jameslamb Apr 18, 2023
9acbc3d
update CI scripts
jameslamb Apr 18, 2023
258ea5a
update docs
jameslamb Apr 18, 2023
ba5db2e
ensure all expected files are included
jameslamb Apr 18, 2023
25984ec
fix things
jameslamb Apr 18, 2023
3bd4757
merge master
jameslamb Apr 18, 2023
8330c81
fix --precompile
jameslamb Apr 18, 2023
4737691
fix windows builds
jameslamb Apr 19, 2023
553310b
more Windows fixes
jameslamb Apr 19, 2023
22d0e59
try to fix Windows builds
jameslamb Apr 19, 2023
4ffa63d
Windows is fun
jameslamb Apr 19, 2023
ddbfe9b
build a wheel when 'install' is called without '--precompile'
jameslamb Apr 19, 2023
874d556
get better logs on MINGW Appveyor build
jameslamb Apr 19, 2023
9ceef1a
work around sh.exe issue on mingw
jameslamb Apr 20, 2023
0984609
quoting is hard
jameslamb Apr 20, 2023
41fb149
re-enable appveyor MSVC
jameslamb Apr 20, 2023
7a647cf
add comment
jameslamb Apr 20, 2023
91227aa
add doccs to build script
jameslamb Apr 20, 2023
c7456da
grammar
jameslamb Apr 20, 2023
34b5f1a
merge use-a-script
jameslamb May 3, 2023
f39a374
fix paths
jameslamb May 3, 2023
289666e
fix missed conflict marker
jameslamb May 3, 2023
2b2ea5d
add MinGW support
jameslamb May 4, 2023
464501c
merge master
jameslamb May 5, 2023
c682523
revert unnecessary changes
jameslamb May 5, 2023
b843ece
more small fixes
jameslamb May 5, 2023
ca3fb04
Merge branch 'master' into python-static-metadata
jameslamb May 6, 2023
4feed80
remove old compile/ paths
jameslamb May 6, 2023
8fdd0fd
remove testing-only stuff
jameslamb May 6, 2023
74ed6f6
merge master
jameslamb May 6, 2023
a203340
add --bit32
jameslamb May 7, 2023
7761cf8
Merge branch 'master' into python-static-metadata
jameslamb May 8, 2023
d545eec
add -DBUILD_CLI flag
jameslamb May 8, 2023
0c6b187
revert
jameslamb May 8, 2023
57b70a1
merge master
jameslamb May 9, 2023
817b4af
fix script
jameslamb May 9, 2023
ee7476b
try to fix things
jameslamb May 9, 2023
3d995e8
change strategy for paths in CMakeLists
jameslamb May 9, 2023
0b380bf
fix paths
jameslamb May 10, 2023
641d26a
Merge branch 'master' into python-static-metadata
jameslamb May 10, 2023
b34c660
update docs, remove pip pinning workaround
jameslamb May 10, 2023
91b68f6
start adding MSBuild docs
jameslamb May 10, 2023
751d432
add support for --precompile from MSBuild
jameslamb May 11, 2023
404b31e
x
jameslamb May 11, 2023
81fce5e
merge master
jameslamb May 29, 2023
3214a0a
Merge branch 'python-static-metadata' of github.com:microsoft/LightGB…
jameslamb May 29, 2023
65be071
Merge branch 'master' into python-static-metadata
jameslamb May 31, 2023
1ca0acb
Merge branch 'master' into python-static-metadata
jameslamb Jun 1, 2023
f2a850f
fix inet_pton stuff
jameslamb Jun 1, 2023
ae72139
more logs
jameslamb Jun 1, 2023
43ab386
maybe using an older scikit-build-core
jameslamb Jun 2, 2023
bfcb1b5
Merge branch 'python-static-metadata' of github.com:microsoft/LightGB…
jameslamb Jun 2, 2023
5eabb0a
v0.4.0
jameslamb Jun 2, 2023
bd10f2e
fix version specifier
jameslamb Jun 2, 2023
6c1ddac
set source_dir
jameslamb Jun 4, 2023
cdb4628
use correct key
jameslamb Jun 4, 2023
2341507
fix config again
jameslamb Jun 4, 2023
77b0ed1
remove unnecessary Boost files
jameslamb Jun 5, 2023
73df701
add more logging
jameslamb Jun 5, 2023
985c8d4
more stuff
jameslamb Jun 5, 2023
3a6e388
remove source-dir
jameslamb Jun 5, 2023
7058a22
higher ninja version
jameslamb Jun 5, 2023
5360f53
support Ninja
jameslamb Jun 6, 2023
1e9916c
merge master
jameslamb Jun 9, 2023
cee5d57
merge master
jameslamb Jun 9, 2023
4da614a
clean up some stuff
jameslamb Jun 9, 2023
b24ec30
remove more debugging stuff
jameslamb Jun 9, 2023
4414897
make Windows tag explicit
jameslamb Jun 9, 2023
41badff
use --config-settings (with an 's') for pip
jameslamb Jun 9, 2023
695aecd
Merge branch 'master' into python-static-metadata
jameslamb Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ elif [[ $TASK == "bdist" ]]; then
sh $BUILD_DIRECTORY/.ci/check_python_dists.sh $BUILD_DIRECTORY/dist || exit -1
mv \
./dist/*.whl \
./dist/tmp.whl || exit -1
mv \
./dist/tmp.whl \
dist/lightgbm-$LGB_VER-py3-none-macosx_10_15_x86_64.macosx_11_6_x86_64.macosx_12_5_x86_64.whl || exit -1
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
cp dist/lightgbm-$LGB_VER-py3-none-macosx*.whl $BUILD_ARTIFACTSTAGINGDIRECTORY || exit -1
Expand All @@ -173,6 +176,9 @@ elif [[ $TASK == "bdist" ]]; then
cd $BUILD_DIRECTORY && sh ./build-python.sh bdist_wheel --integrated-opencl || exit -1
mv \
./dist/*.whl \
./dist/tmp.whl || exit -1
mv \
./dist/tmp.whl \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two-step process avoids the error:

mv: './dist/lightgbm-3.3.5.99-py3-none-manylinux_2_28_x86_64.whl' and './dist/lightgbm-3.3.5.99-py3-none-manylinux_2_28_x86_64.whl' are the same file

caused by the fact the scikit-build-core automatically produces the correct platform tag, but this script defensively assumes that wheel tags need to be corrected 😀

./dist/lightgbm-$LGB_VER-py3-none-$PLATFORM.whl || exit -1
sh $BUILD_DIRECTORY/.ci/check_python_dists.sh $BUILD_DIRECTORY/dist || exit -1
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
Expand All @@ -186,12 +192,6 @@ elif [[ $TASK == "bdist" ]]; then
exit 0
fi

# temporarily pin pip to versions that support 'pip install --install-option'
# ref: https://github.com/microsoft/LightGBM/issues/5061#issuecomment-1510642287
if [[ $METHOD == "pip" ]]; then
pip install 'pip<23.1'
fi

if [[ $TASK == "gpu" ]]; then
sed -i'.bak' 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' $BUILD_DIRECTORY/include/LightGBM/config.h
grep -q 'std::string device_type = "gpu"' $BUILD_DIRECTORY/include/LightGBM/config.h || exit -1 # make sure that changes were really done
Expand All @@ -201,7 +201,7 @@ if [[ $TASK == "gpu" ]]; then
pip install \
--user \
-v \
--install-option=--gpu \
--config-setting=cmake.define.USE_GPU=ON \
$BUILD_DIRECTORY/dist/lightgbm-$LGB_VER.tar.gz \
|| exit -1
pytest $BUILD_DIRECTORY/tests/python_package_test || exit -1
Expand Down Expand Up @@ -229,7 +229,7 @@ elif [[ $TASK == "cuda" ]]; then
pip install \
--user \
-v \
--install-option=--cuda \
--config-setting=cmake.define.USE_CUDA=ON \
$BUILD_DIRECTORY/dist/lightgbm-$LGB_VER.tar.gz \
|| exit -1
pytest $BUILD_DIRECTORY/tests/python_package_test || exit -1
Expand All @@ -252,7 +252,7 @@ elif [[ $TASK == "mpi" ]]; then
pip install \
--user \
-v \
--install-option=--mpi \
--config-setting=cmake.define.USE_MPI=ON \
$BUILD_DIRECTORY/dist/lightgbm-$LGB_VER.tar.gz \
|| exit -1
pytest $BUILD_DIRECTORY/tests/python_package_test || exit -1
Expand Down
4 changes: 2 additions & 2 deletions .ci/test_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ elseif ($env:TASK -eq "bdist") {
cd $env:BUILD_SOURCESDIRECTORY
sh "build-python.sh" bdist_wheel --integrated-opencl ; Check-Output $?
sh $env:BUILD_SOURCESDIRECTORY/.ci/check_python_dists.sh $env:BUILD_SOURCESDIRECTORY/dist ; Check-Output $?
cd dist; pip install --user @(Get-ChildItem *.whl) ; Check-Output $?
cp @(Get-ChildItem *.whl) $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cd dist; pip install --user @(Get-ChildItem *py3-none-win_amd64.whl) ; Check-Output $?
cp @(Get-ChildItem *py3-none-win_amd64.whl) $env:BUILD_ARTIFACTSTAGINGDIRECTORY
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures we get a loud error if the wheels are not tagged in the way we'd expect.

Since as far as I can tell, you can't pass a --plat-name through python -m build the way you could with python setup.py bdist_wheel --plat-name=win-amd64.

To be clear... scikit-build-core is doing exactly the right thing here and producing the expected tags. This is just a precaution to help us detect if that changes, before publishing mistagged wheels to PyPI (e.g. like #4788).

} elseif (($env:APPVEYOR -eq "true") -and ($env:TASK -eq "python")) {
cd $env:BUILD_SOURCESDIRECTORY
if ($env:COMPILER -eq "MINGW") {
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ if(BUILD_CLI)
)
endif()

if(__BUILD_FOR_PYTHON)
set(CMAKE_INSTALL_PREFIX "lightgbm")
endif()

install(
TARGETS _lightgbm
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
Expand Down
146 changes: 90 additions & 56 deletions build-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,75 +94,79 @@ while [ $# -gt 0 ]; do
then shift;
fi
BOOST_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --boost-dir='${BOOST_DIR}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_DIR='${BOOST_DIR}'"
guolinke marked this conversation as resolved.
Show resolved Hide resolved
;;
--boost-include-dir|--boost-include-dir=*)
if [[ "$1" != *=* ]];
then shift;
fi
BOOST_INCLUDE_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --boost-include-dir='${BOOST_INCLUDE_DIR}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_INCLUDE_DIR='${BOOST_INCLUDE_DIR}'"
;;
--boost-librarydir|--boost-librarydir=*)
if [[ "$1" != *=* ]];
then shift;
fi
BOOST_LIBRARY_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --boost-librarydir='${BOOST_LIBRARY_DIR}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.BOOST_LIBRARYDIR='${BOOST_LIBRARY_DIR}'"
;;
--boost-root|--boost-root=*)
if [[ "$1" != *=* ]];
then shift;
fi
BOOST_ROOT="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --boost-root='${BOOST_ROOT}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.Boost_ROOT='${BOOST_ROOT}'"
;;
--opencl-include-dir|--opencl-include-dir=*)
if [[ "$1" != *=* ]];
then shift;
fi
OPENCL_INCLUDE_DIR="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --opencl-include-dir='${OPENCL_INCLUDE_DIR}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.OpenCL_INCLUDE_DIR='${OPENCL_INCLUDE_DIR}'"
;;
--opencl-library|--opencl-library=*)
if [[ "$1" != *=* ]];
then shift;
fi
OPENCL_LIBRARY="${1#*=}"
BUILD_ARGS="${BUILD_ARGS} --opencl-library='${OPENCL_LIBRARY}'"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.OpenCL_LIBRARY='${OPENCL_LIBRARY}'"
;;
#########
# flags #
#########
--bit32)
BUILD_ARGS="${BUILD_ARGS} --bit32"
export CMAKE_GENERATOR="Visual Studio 17 2022"
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}'."
;;
--cuda)
BUILD_ARGS="${BUILD_ARGS} --cuda"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_CUDA=ON"
;;
--gpu)
BUILD_ARGS="${BUILD_ARGS} --gpu"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_GPU=ON"
;;
--hdfs)
BUILD_ARGS="${BUILD_ARGS} --hdfs"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_HDFS=ON"
;;
--integrated-opencl)
BUILD_ARGS="${BUILD_ARGS} --integrated-opencl"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.__INTEGRATE_OPENCL=ON"
;;
--mingw)
BUILD_ARGS="${BUILD_ARGS} --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"
;;
--mpi)
BUILD_ARGS="${BUILD_ARGS} --mpi"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_MPI=ON"
;;
--nomp)
BUILD_ARGS="${BUILD_ARGS} --nomp"
BUILD_ARGS="${BUILD_ARGS} --config-setting=cmake.define.USE_OPENMP=OFF"
;;
--precompile)
PRECOMPILE="true"
;;
--time-costs)
BUILD_ARGS="${PIP_INSTALL_ARGS} --time-costs"
BUILD_ARGS="${PIP_INSTALL_ARGS} --config-setting=cmake.define.USE_TIMETAG=ON"
;;
--user)
PIP_INSTALL_ARGS="${PIP_INSTALL_ARGS} --user"
Expand All @@ -175,6 +179,8 @@ while [ $# -gt 0 ]; do
shift
done

pip install --prefer-binary 'build>=0.10.0'

# create a new directory that just contains the files needed
# to build the Python package
create_isolated_source_dir() {
Expand All @@ -189,21 +195,15 @@ create_isolated_source_dir() {

cp -R ./python-package ./lightgbm-python

# temporarily remove these files until
# https://github.com/microsoft/LightGBM/issues/5061 is done
rm ./lightgbm-python/pyproject.toml
rm ./lightgbm-python/setup.cfg

cp LICENSE ./lightgbm-python/
cp VERSION.txt ./lightgbm-python/lightgbm/VERSION.txt

mkdir -p ./lightgbm-python/compile
cp -R ./cmake ./lightgbm-python/compile
cp CMakeLists.txt ./lightgbm-python/compile
cp -R ./include ./lightgbm-python/compile
cp -R ./src ./lightgbm-python/compile
cp -R ./swig ./lightgbm-python/compile
cp -R ./windows ./lightgbm-python/compile
cp -R ./cmake ./lightgbm-python
cp CMakeLists.txt ./lightgbm-python
cp -R ./include ./lightgbm-python
cp -R ./src ./lightgbm-python
cp -R ./swig ./lightgbm-python
cp -R ./windows ./lightgbm-python

# include only specific files from external_libs, to keep the package
# small and avoid redistributing code with licenses incompatible with
Expand All @@ -212,77 +212,77 @@ create_isolated_source_dir() {
######################
# fast_double_parser #
######################
mkdir -p ./lightgbm-python/compile/external_libs/fast_double_parser
mkdir -p ./lightgbm-python/external_libs/fast_double_parser
cp \
external_libs/fast_double_parser/CMakeLists.txt \
./lightgbm-python/compile/external_libs/fast_double_parser/CMakeLists.txt
./lightgbm-python/external_libs/fast_double_parser/CMakeLists.txt
cp \
external_libs/fast_double_parser/LICENSE* \
./lightgbm-python/compile/external_libs/fast_double_parser/
./lightgbm-python/external_libs/fast_double_parser/

mkdir -p ./lightgbm-python/compile/external_libs/fast_double_parser/include/
mkdir -p ./lightgbm-python/external_libs/fast_double_parser/include/
cp \
external_libs/fast_double_parser/include/fast_double_parser.h \
./lightgbm-python/compile/external_libs/fast_double_parser/include/
./lightgbm-python/external_libs/fast_double_parser/include/

#######
# fmt #
#######
mkdir -p ./lightgbm-python/compile/external_libs/fmt
mkdir -p ./lightgbm-python/external_libs/fmt
cp \
external_libs/fast_double_parser/CMakeLists.txt \
./lightgbm-python/compile/external_libs/fmt/CMakeLists.txt
./lightgbm-python/external_libs/fmt/CMakeLists.txt
cp \
external_libs/fmt/LICENSE* \
./lightgbm-python/compile/external_libs/fmt/
./lightgbm-python/external_libs/fmt/

mkdir -p ./lightgbm-python/compile/external_libs/fmt/include/fmt
mkdir -p ./lightgbm-python/external_libs/fmt/include/fmt
cp \
external_libs/fmt/include/fmt/*.h \
./lightgbm-python/compile/external_libs/fmt/include/fmt/
./lightgbm-python/external_libs/fmt/include/fmt/

#########
# Eigen #
#########
mkdir -p ./lightgbm-python/compile/external_libs/eigen/Eigen
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen
cp \
external_libs/eigen/CMakeLists.txt \
./lightgbm-python/compile/external_libs/eigen/CMakeLists.txt
./lightgbm-python/external_libs/eigen/CMakeLists.txt

modules="Cholesky Core Dense Eigenvalues Geometry Householder Jacobi LU QR SVD"
for eigen_module in ${modules}; do
cp \
external_libs/eigen/Eigen/${eigen_module} \
./lightgbm-python/compile/external_libs/eigen/Eigen/${eigen_module}
./lightgbm-python/external_libs/eigen/Eigen/${eigen_module}
if [ ${eigen_module} != "Dense" ]; then
mkdir -p ./lightgbm-python/compile/external_libs/eigen/Eigen/src/${eigen_module}/
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/
cp \
-R \
external_libs/eigen/Eigen/src/${eigen_module}/* \
./lightgbm-python/compile/external_libs/eigen/Eigen/src/${eigen_module}/
./lightgbm-python/external_libs/eigen/Eigen/src/${eigen_module}/
fi
done

mkdir -p ./lightgbm-python/compile/external_libs/eigen/Eigen/misc
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/misc
cp \
-R \
external_libs/eigen/Eigen/src/misc \
./lightgbm-python/compile/external_libs/eigen/Eigen/src/misc/
./lightgbm-python/external_libs/eigen/Eigen/src/misc/

mkdir -p ./lightgbm-python/compile/external_libs/eigen/Eigen/plugins
mkdir -p ./lightgbm-python/external_libs/eigen/Eigen/plugins
cp \
-R \
external_libs/eigen/Eigen/src/plugins \
./lightgbm-python/compile/external_libs/eigen/Eigen/src/plugins/
./lightgbm-python/external_libs/eigen/Eigen/src/plugins/

###################
# compute (Boost) #
###################
mkdir -p ./lightgbm-python/compile/external_libs/compute
mkdir -p ./lightgbm-python/external_libs/compute
cp \
-R \
external_libs/compute/include \
./lightgbm-python/compile/external_libs/compute/include/
./lightgbm-python/external_libs/compute/include/
}

create_isolated_source_dir
Expand All @@ -292,9 +292,39 @@ cd ./lightgbm-python
# installation involves building the wheel + `pip install`-ing it
if test "${INSTALL}" = true; then
if test "${PRECOMPILE}" = true; then
echo "--- installing lightgbm (from precompiled lib_lightgbm) ---"
python setup.py install ${PIP_INSTALL_ARGS} --precompile
exit 0
BUILD_SDIST=true
BUILD_WHEEL=false
BUILD_ARGS=""
rm -rf \
./cmake \
./CMakeLists.txt \
./external_libs \
./include \
./src \
./swig \
./windows
# use regular-old setuptools for these builds, to avoid
# trying to recompile the shared library
sed -i.bak -e '/start:build-system/,/end:build-system/d' pyproject.toml
echo '[build-system]' >> ./pyproject.toml
echo 'requires = ["setuptools"]' >> ./pyproject.toml
echo 'build-backend = "setuptools.build_meta"' >> ./pyproject.toml
echo "" >> ./pyproject.toml
echo "recursive-include lightgbm *.dll *.so" > ./MANIFEST.in
echo "" >> ./MANIFEST.in
mkdir -p ./lightgbm/lib
if test -f ../lib_lightgbm.so; then
echo "found pre-compiled lib_lightgbm.so"
cp ../lib_lightgbm.so ./lightgbm/lib/lib_lightgbm.so
elif test -f ../Release/lib_lightgbm.dll; then
echo "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"
cp ../windows/x64/DLL/lib_lightgbm.dll ./lightgbm/lib/lib_lightgbm.dll
cp ../windows/x64/DLL/lib_lightgbm.lib ./lightgbm/lib/lib_lightgbm.lib
fi
rm -f ./*.bak
else
BUILD_SDIST="false"
BUILD_WHEEL="true"
Expand All @@ -304,16 +334,20 @@ fi
if test "${BUILD_SDIST}" = true; then
echo "--- building sdist ---"
rm -f ../dist/*.tar.gz
python ./setup.py sdist \
--dist-dir ../dist
python -m build \
--sdist \
--outdir ../dist \
.
fi

if test "${BUILD_WHEEL}" = true; then
echo "--- building wheel ---"
rm -f ../dist/*.whl || true
python setup.py bdist_wheel \
--dist-dir ../dist \
${BUILD_ARGS}
python -m build \
--wheel \
--outdir ../dist \
${BUILD_ARGS} \
.
fi

if test "${INSTALL}" = true; then
Expand Down
Loading