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] upgrade to scikit-build-core 0.9.3 #6263

Merged
merged 12 commits into from
May 8, 2024
12 changes: 8 additions & 4 deletions python-package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,30 @@ changelog = "https://github.com/microsoft/LightGBM/releases"
# start:build-system
[build-system]

requires = ["scikit-build-core>=0.4.4"]
requires = ["scikit-build-core>=0.9.3"]
build-backend = "scikit_build_core.build"

# based on https://github.com/scikit-build/scikit-build-core#configuration
[tool.scikit-build]

cmake.minimum-version = "3.18"
ninja.minimum-version = "1.11"
cmake.version = ">=3.18"
ninja.version = ">=1.11"
ninja.make-fallback = true
cmake.args = [
"-D__BUILD_FOR_PYTHON:BOOL=ON"
]
cmake.verbose = false
cmake.build-type = "Release"
cmake.targets = ["_lightgbm"]
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 that only the shared library is built, and not other targets like the CLI or headers.

scikit-build-core didn't support that back when we did #5759, which is why this exists:

LightGBM/CMakeLists.txt

Lines 54 to 60 in 88cec47

if(__BUILD_FOR_PYTHON OR __BUILD_FOR_R)
# the Python and R package don't require the CLI
set(BUILD_CLI OFF)
# installing the R and Python package shouldn't place LightGBM's headers
# outside of where the package is installed
set(INSTALL_HEADERS OFF)
endif()

I'd like to leave that in CMakeLists.txt as extra protection for now. It's only a tiny bit of complexity in exchange for protection against some potentially-impactful side effects (like pip install of an sdist placing LightGBM's headers somewhere outside of where pip manages files).

# stripping binaries should be turned back on once this is fixed:
# https://github.com/jameslamb/pydistcheck/issues/235
install.strip = false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See jameslamb/pydistcheck#235 for a full description of this.

Short description: it's great that scikit-build-core strips binaries by default now, but we don't need it in LightGBM. And pydistcheck's check on debug symbols (which runs in CI) gives us confidence that no debug symbols sneak into compiled objects in wheels.

logging.level = "INFO"
sdist.reproducible = true
wheel.py-api = "py3"
experimental = false
strict-config = true
minimum-version = "0.4.4"
minimum-version = "0.9.3"

# end:build-system

Expand Down
Loading