Skip to content

Commit 3fe7fda

Browse files
jase231siliataider
authored andcommitted
[build] Migrate build backend to scikit-build-core
1 parent ff798f9 commit 3fe7fda

3 files changed

Lines changed: 86 additions & 189 deletions

File tree

bindings/pyroot/pythonizations/python/ROOT/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import types
1919
from importlib.abc import Loader, MetaPathFinder
2020
from importlib.machinery import ModuleSpec
21+
from importlib.metadata import PackageNotFoundError, version
2122

2223
from . import _asan # noqa: F401 # imported for side effects for setup specific to AddressSanitizer environments
2324
from ._facade import ROOTFacade
@@ -190,6 +191,28 @@ def find_spec(self, fullname: str, path, target=None) -> ModuleSpec:
190191

191192
# from . import JsMVA
192193

194+
# importlib.metadata.version reads distribution metadata from the package's
195+
# .dist-info folder, which is typically generated by the package manager.
196+
# An installed ROOT wheel distribution will contain this metadata,
197+
# and version("ROOT") will succeed. However, ROOT built or installed
198+
# through any other channel (e.g. from source) has no .dist-info folder,
199+
# so the corresponding metadata is missing, therefore version("ROOT") raises
200+
# PackageNotFoundError, despite `import ROOT` succeeding in the same environment.
201+
# See: https://docs.python.org/3/library/importlib.metadata.html
202+
try:
203+
if "a" in version("ROOT"):
204+
import warnings
205+
206+
warnings.warn(
207+
"This distribution of ROOT is in alpha stage. Feedback is welcome and appreciated. "
208+
"Feel free to reach out to the user forum for questions and general feedback at "
209+
"https://github.com/root-project/root/issues. "
210+
"Do not rely on this distribution for production purposes.",
211+
stacklevel=2, # emit the warning in the caller
212+
)
213+
except PackageNotFoundError:
214+
pass
215+
193216

194217
def _cleanup():
195218
# Delete TBrowser instances while the GUI event loop is still alive,

pyproject.toml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[build-system]
2-
requires = ["cmake", "setuptools<72", "wheel", "numpy"]
2+
requires = ["scikit-build-core>=0.10"]
3+
build-backend = "scikit_build_core.build"
34

45
[project]
5-
name = "ROOT"
6+
name = "root"
67
version = "0.1a12"
78
requires-python = ">=3.10"
89
maintainers = [
@@ -15,16 +16,73 @@ dependencies = [
1516
"numpy",
1617
]
1718

18-
# Demonstrate how to expose ROOT CLI tools the Python way. For now only include
19-
# `root`, other tools can be added later using the same approach.
19+
# Point backend to python packages and to explicitly use Ninja
20+
[tool.scikit-build]
21+
wheel.packages = [
22+
"bindings/pyroot/pythonizations/python/ROOT",
23+
"bindings/pyroot/cppyy/cppyy/python/cppyy",
24+
]
25+
cmake.args = [
26+
"-GNinja",
27+
]
28+
29+
[tool.scikit-build.cmake.define]
30+
# CMake install directories
31+
CMAKE_INSTALL_BINDIR = "ROOT/bin"
32+
CMAKE_INSTALL_CMAKEDIR = "ROOT/cmake"
33+
CMAKE_INSTALL_FONTDIR = "ROOT/fonts"
34+
CMAKE_INSTALL_ICONDIR = "ROOT/icons"
35+
CMAKE_INSTALL_INCLUDEDIR = "ROOT/include"
36+
CMAKE_INSTALL_LIBDIR = "ROOT/lib"
37+
CMAKE_INSTALL_MACRODIR = "ROOT/macros"
38+
CMAKE_INSTALL_MANDIR = "ROOT/man"
39+
CMAKE_INSTALL_PYTHONDIR = "."
40+
CMAKE_INSTALL_SYSCONFDIR = "ROOT/etc"
41+
CMAKE_INSTALL_TUTDIR = "ROOT/tutorials"
42+
43+
# Generic minimal build config
44+
gminimal="ON"
45+
asimage="ON"
46+
opengl="OFF"
47+
runtime_cxxmodules="ON"
48+
fail-on-missing="ON"
49+
50+
# Explicitly list components that gminimal implicitly turns off as documentation
51+
# tmva-pymva and tpython are disabled for manylinux compatibility
52+
# see https://peps.python.org/pep-0513/#libpythonx-y-so-1
53+
tmva-pymva="OFF"
54+
tpython="OFF"
55+
thisroot_scripts="OFF" # the thisroot.* scripts are broken if CMAKE_INSTALL_PYTHONDIR!=CMAKE_INSTALL_LIBDIR
56+
57+
# Builtins
58+
builtin_nlohmannjson="ON"
59+
builtin_tbb="ON"
60+
builtin_xrootd="ON"
61+
builtin_tiff="ON"
62+
builtin_lz4="ON"
63+
builtin_fftw3="ON"
64+
builtin_gsl="ON"
65+
builtin_lzma="ON"
66+
builtin_zstd="ON"
67+
builtin_xxhash="ON"
68+
pyroot="ON"
69+
dataframe="ON"
70+
xrootd="ON"
71+
ssl="ON"
72+
imt="ON"
73+
roofit="ON"
74+
mathmore="ON"
75+
76+
# Expose the ROOT cli as an executable command via _rootcli wrapper
2077
[project.scripts]
2178
root = "ROOT._rootcli:main"
2279

2380
[tool.cibuildwheel]
24-
# Increase pip debugging output
81+
build-frontend = { name = "build" }
2582
build-verbosity = 1
2683
manylinux-x86_64-image = "manylinux_2_28"
2784

2885
# Install system libraries
2986
[tool.cibuildwheel.linux]
3087
before-all = "dnf install -y epel-release && /usr/bin/crb enable && dnf install -y openssl-devel libX11-devel libXpm-devel libXft-devel libXext-devel libuuid-devel libjpeg-devel giflib-devel libtiff-devel"
88+

setup.py

Lines changed: 0 additions & 184 deletions
This file was deleted.

0 commit comments

Comments
 (0)