Skip to content

Commit 47abcb0

Browse files
authored
Merge branch 'master' into use-auditwheel
2 parents e86422f + 6af94aa commit 47abcb0

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

build-python.sh

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ create_isolated_source_dir
289289

290290
cd ./lightgbm-python
291291

292-
# installation involves building the wheel + `pip install`-ing it
292+
# if 'install' was passed, choose the type of package to build and install
293293
if test "${INSTALL}" = true; then
294294
if test "${PRECOMPILE}" = true; then
295-
BUILD_SDIST=true
296-
BUILD_WHEEL=false
295+
BUILD_SDIST=false
296+
BUILD_WHEEL=true
297297
BUILD_ARGS=""
298298
rm -rf \
299299
./cmake \
@@ -302,16 +302,22 @@ if test "${INSTALL}" = true; then
302302
./include \
303303
./src \
304304
./swig
305-
# use regular-old setuptools for these builds, to avoid
306-
# trying to recompile the shared library
305+
# avoid trying to recompile, just use hatchling and copy in relevant files
307306
sed -i.bak -e '/start:build-system/,/end:build-system/d' pyproject.toml
308-
# shellcheck disable=SC2129
309-
echo '[build-system]' >> ./pyproject.toml
310-
echo 'requires = ["setuptools"]' >> ./pyproject.toml
311-
echo 'build-backend = "setuptools.build_meta"' >> ./pyproject.toml
312-
echo "" >> ./pyproject.toml
313-
echo "recursive-include lightgbm *.dll *.dylib *.so" > ./MANIFEST.in
314-
echo "" >> ./MANIFEST.in
307+
308+
# replace build backend configuration
309+
cat >> ./pyproject.toml <<EOF
310+
311+
[build-system]
312+
requires = ["hatchling>=1.27.0"]
313+
build-backend = "hatchling.build"
314+
315+
[tool.hatch.build.targets.wheel]
316+
# do not consider .gitignore when choosing files to include / exclude
317+
ignore-vcs = true
318+
packages = ["lightgbm"]
319+
320+
EOF
315321
mkdir -p ./lightgbm/lib
316322
if test -f ../lib_lightgbm.so; then
317323
echo "[INFO] found pre-compiled lib_lightgbm.so"
@@ -338,7 +344,11 @@ if test "${INSTALL}" = true; then
338344
exit 1
339345
fi
340346
rm -f ./*.bak
341-
else
347+
fi
348+
349+
# at this point, if 'install' was passed but the package type wasn't indicated, prefer wheel
350+
if test "${BUILD_SDIST}" = false && test "${BUILD_WHEEL}" = false; then
351+
echo "[INFO] 'install' passed but no package type ('bdist_wheel', 'sdist') chosen. Defaulting to 'bdist_wheel'."
342352
BUILD_SDIST="false"
343353
BUILD_WHEEL="true"
344354
fi
@@ -366,22 +376,19 @@ fi
366376

367377
if test "${INSTALL}" = true; then
368378
echo "[INFO] --- installing lightgbm ---"
369-
cd ../dist
379+
cd ..
370380
if test "${BUILD_WHEEL}" = true; then
371-
PACKAGE_NAME="$(echo lightgbm*.whl)"
381+
PACKAGE_FILE="$(echo dist/lightgbm*.whl)"
372382
else
373-
PACKAGE_NAME="$(echo lightgbm*.tar.gz)"
383+
PACKAGE_FILE="$(echo dist/lightgbm*.tar.gz)"
374384
fi
375-
# ref for use of '--find-links': https://stackoverflow.com/a/52481267/3986677
376385
# shellcheck disable=SC2086
377386
pip install \
378387
${PIP_INSTALL_ARGS} \
379388
--force-reinstall \
380389
--no-cache-dir \
381390
--no-deps \
382-
--find-links=. \
383-
"${PACKAGE_NAME}"
384-
cd ../
391+
"${PACKAGE_FILE}"
385392
fi
386393

387394
echo "[INFO] cleaning up"

docs/GPU-Tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ If you want to use the Python interface of LightGBM, you can install it now (alo
7373

7474
::
7575

76-
sudo apt-get -y install python-pip
77-
sudo -H pip install setuptools numpy scipy scikit-learn -U
76+
sudo apt-get -y install python3-pip python3-venv
77+
sudo -H pip install numpy scipy scikit-learn -U
7878
sudo sh ./build-python.sh install --precompile
7979

8080
You need to set an additional parameter ``"device" : "gpu"`` (along with your other options like ``learning_rate``, ``num_leaves``, etc) to use GPU in Python.

python-package/pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
classifiers = [
44
"Development Status :: 5 - Production/Stable",
55
"Intended Audience :: Science/Research",
6-
"License :: OSI Approved :: MIT License",
76
"Natural Language :: English",
87
"Operating System :: MacOS",
98
"Operating System :: Microsoft :: Windows",
@@ -22,7 +21,10 @@ dependencies = [
2221
"scipy"
2322
]
2423
description = "LightGBM Python-package"
25-
license = {file = "LICENSE"}
24+
license = "MIT"
25+
license-files = [
26+
"LICENSE"
27+
]
2628
maintainers = [
2729
{name = "Yu Shi", email = "[email protected]"}
2830
]
@@ -60,7 +62,7 @@ changelog = "https://github.com/microsoft/LightGBM/releases"
6062
# start:build-system
6163
[build-system]
6264

63-
requires = ["scikit-build-core>=0.10.1"]
65+
requires = ["scikit-build-core>=0.11.0"]
6466
build-backend = "scikit_build_core.build"
6567

6668
# based on https://github.com/scikit-build/scikit-build-core#configuration

0 commit comments

Comments
 (0)