Skip to content

Commit b2cf885

Browse files
committed
Switch to scikit-build core
1 parent 1429887 commit b2cf885

File tree

5 files changed

+239
-350
lines changed

5 files changed

+239
-350
lines changed

CMakeLists.txt

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,152 @@ execute_process(
1515
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
1616
find_package(nanobind CONFIG REQUIRED)
1717

18+
option(USE_SHIPPED_ISL "Use shipped ISL" 1)
19+
option(USE_SHIPPED_IMATH "Use shipped IMATH" 1)
20+
option(USE_IMATH_FOR_MP "Use IMATH for multiprecision arithmetic" 1)
21+
option(USE_IMATH_SIO "Use IMATH small-integer optimization" 1)
22+
option(USE_GMP_FOR_MP "Use GMP" 0)
23+
option(USE_BARVINOK "Use Barvinok (beware of GPL license)" 0)
24+
25+
if(USE_SHIPPED_ISL)
26+
if(USE_BARVINOK)
27+
message(FATAL_ERROR "Using barvinok is not compatible with shipped ISL")
28+
endif()
29+
set(ISL_SOURCES
30+
isl/isl_schedule.c
31+
isl/isl_ast_build_expr.c
32+
isl/isl_sample.c
33+
isl/isl_coalesce.c
34+
isl/isl_fold.c
35+
isl/isl_schedule_read.c
36+
isl/isl_aff_map.c
37+
isl/isl_scheduler_clustering.c
38+
isl/isl_flow.c
39+
isl/isl_map_subtract.c
40+
isl/uset_to_umap.c
41+
isl/isl_hash.c
42+
isl/isl_aff.c
43+
isl/isl_transitive_closure.c
44+
isl/isl_map_simplify.c
45+
isl/print.c
46+
isl/basis_reduction_tab.c
47+
isl/isl_schedule_constraints.c
48+
isl/isl_sort.c
49+
isl/isl_ast.c
50+
isl/bset_to_bmap.c
51+
isl/bset_from_bmap.c
52+
isl/isl_schedule_band.c
53+
isl/isl_bernstein.c
54+
isl/uset_from_umap.c
55+
isl/isl_scheduler.c
56+
isl/isl_set_to_ast_graft_list.c
57+
isl/isl_convex_hull.c
58+
isl/isl_schedule_tree.c
59+
isl/isl_tarjan.c
60+
isl/isl_equalities.c
61+
isl/isl_constraint.c
62+
isl/isl_union_map.c
63+
isl/isl_bound.c
64+
isl/isl_stride.c
65+
isl/set_list_from_map_list_inl.c
66+
isl/isl_farkas.c
67+
isl/isl_tab_pip.c
68+
isl/set_to_map.c
69+
isl/set_from_map.c
70+
isl/isl_lp.c
71+
isl/isl_ffs.c
72+
isl/isl_id_to_ast_expr.c
73+
isl/isl_val.c
74+
isl/isl_set_list.c
75+
isl/isl_space.c
76+
isl/isl_tab.c
77+
isl/isl_map.c
78+
isl/isl_version.c
79+
isl/isl_stream.c
80+
isl/isl_local_space.c
81+
isl/isl_id_to_pw_aff.c
82+
isl/isl_ilp.c
83+
isl/isl_range.c
84+
isl/isl_point.c
85+
isl/isl_schedule_node.c
86+
isl/isl_polynomial.c
87+
isl/isl_options.c
88+
isl/isl_morph.c
89+
isl/isl_deprecated.c
90+
isl/isl_ctx.c
91+
isl/isl_seq.c
92+
isl/isl_box.c
93+
isl/isl_output.c
94+
isl/isl_factorization.c
95+
isl/isl_printer.c
96+
isl/dep.c
97+
isl/isl_id_to_id.c
98+
isl/isl_ast_build.c
99+
isl/isl_ast_codegen.c
100+
isl/isl_obj.c
101+
isl/isl_scheduler_scc.c
102+
isl/isl_vec.c
103+
isl/isl_map_list.c
104+
isl/isl_vertices.c
105+
isl/isl_arg.c
106+
isl/isl_mat.c
107+
isl/isl_id.c
108+
isl/isl_affine_hull.c
109+
isl/isl_scan.c
110+
isl/isl_map_to_basic_set.c
111+
isl/isl_blk.c
112+
isl/isl_dim_map.c
113+
isl/isl_local.c
114+
isl/isl_reordering.c
115+
isl/isl_ast_graft.c
116+
isl/isl_input.c
117+
)
118+
set(ISL_INC_DIRS isl-supplementary isl/include isl)
119+
if(USE_IMATH_FOR_MP)
120+
if(USE_SHIPPED_IMATH)
121+
list(APPEND ISL_SOURCES
122+
isl/isl_imath.c
123+
isl/imath/imath.c
124+
isl/imath/imrat.c
125+
isl/imath/gmp_compat.c
126+
)
127+
list(APPEND ISL_INC_DIRS isl/imath)
128+
endif()
129+
if(USE_IMATH_SIO)
130+
list(APPEND ISL_SOURCES
131+
isl/isl_int_sioimath.c
132+
isl/isl_val_sioimath.c
133+
)
134+
endif()
135+
endif()
136+
else()
137+
set(ISL_SOURCES)
138+
endif()
139+
140+
set(ISLPY_GENERATED_SOURCE
141+
${CMAKE_BINARY_DIR}/generated/gen-expose-part1.inc
142+
${CMAKE_BINARY_DIR}/generated/gen-expose-part2.inc
143+
${CMAKE_BINARY_DIR}/generated/gen-expose-part3.inc
144+
${CMAKE_BINARY_DIR}/generated/gen-wrap-part1.inc
145+
${CMAKE_BINARY_DIR}/generated/gen-wrap-part2.inc
146+
${CMAKE_BINARY_DIR}/generated/gen-wrap-part3.inc
147+
)
148+
149+
if(USE_BARVINOK)
150+
set(ISLPY_GENERATION_FLAGS -b)
151+
else()
152+
set(ISLPY_GENERATION_FLAGS)
153+
endif()
154+
155+
add_custom_command(
156+
OUTPUT ${ISLPY_GENERATED_SOURCE}
157+
COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/gen_wrap.py
158+
-o ${CMAKE_BINARY_DIR}/generated
159+
-I ${CMAKE_SOURCE_DIR}
160+
-I ${CMAKE_SOURCE_DIR}/isl/include
161+
${ISLPY_GENERATION_FLAGS}
162+
)
163+
18164
nanobind_add_module(
19165
_isl
20166
NB_STATIC # Build static libnanobind (the extension module itself remains a shared library)
@@ -25,7 +171,9 @@ nanobind_add_module(
25171
src/wrapper/wrap_isl_part2.cpp
26172
src/wrapper/wrap_isl_part3.cpp
27173
${ISL_SOURCES}
174+
${ISLPY_GENERATED_SOURCE}
28175
)
176+
target_include_directories(_isl PRIVATE ${CMAKE_BINARY_DIR}/generated)
29177

30178
# Work around https://github.com/inducer/islpy/issues/120.
31179
# See https://stackoverflow.com/questions/43554227/extern-inline-func-results-in-undefined-reference-error
@@ -54,12 +202,12 @@ endif()
54202
target_include_directories(_isl PRIVATE ${ISL_INC_DIRS})
55203

56204
if(USE_SHIPPED_ISL)
57-
target_compile_definitions(_isl PRIVATE GIT_HEAD_ID="${ISL_GIT_HEAD_ID}")
205+
target_compile_definitions(_isl PRIVATE GIT_HEAD_ID="included-with-islpy")
58206
else()
59207
target_link_directories(_isl PRIVATE ${ISL_LIB_DIRS})
60208
target_link_libraries(_isl PRIVATE ${ISL_LIB_NAMES})
61209
endif()
62210

63-
install(TARGETS _isl LIBRARY DESTINATION .)
211+
install(TARGETS _isl LIBRARY DESTINATION islpy)
64212

65213
# vim: sw=2

gen_wrap.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
THE SOFTWARE.
2121
"""
2222

23+
import argparse
2324
import os
25+
from pathlib import Path
2426
import re
2527
import sys
2628
from collections.abc import Mapping, Sequence
@@ -1530,8 +1532,19 @@ def my_ismethod(method):
15301532
expf.write("\n// }}}\n\n")
15311533

15321534

1533-
def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
1534-
fdata = FunctionData([".", *include_dirs])
1535+
def gen_wrapper(include_dirs: Sequence[str],
1536+
*,
1537+
output_dir: str | None = None,
1538+
include_barvinok: bool = False,
1539+
isl_version: int | None = None
1540+
):
1541+
if output_dir is None:
1542+
output_path = Path(".")
1543+
else:
1544+
output_path = Path(output_dir)
1545+
output_path.mkdir(exist_ok=True)
1546+
1547+
fdata = FunctionData(include_dirs)
15351548
fdata.read_header("isl/ctx.h")
15361549
fdata.read_header("isl/id.h")
15371550
fdata.read_header("isl/space.h")
@@ -1564,8 +1577,8 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
15641577
fdata.read_header("barvinok/isl.h")
15651578

15661579
for part, classes in PART_TO_CLASSES.items():
1567-
expf = open(f"src/wrapper/gen-expose-{part}.inc", "w")
1568-
wrapf = open(f"src/wrapper/gen-wrap-{part}.inc", "w")
1580+
expf = open(output_path / f"gen-expose-{part}.inc", "w")
1581+
wrapf = open(output_path / f"gen-wrap-{part}.inc", "w")
15691582

15701583
classes = [
15711584
cls
@@ -1616,8 +1629,23 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
16161629
wrapf.close()
16171630

16181631

1632+
def main():
1633+
parser = argparse.ArgumentParser()
1634+
parser.add_argument("-I", "--include-dir", nargs="*", default=[".", "isl/include"])
1635+
parser.add_argument("-o", "--output-dir", default=".")
1636+
parser.add_argument("--barvinok", action="store_true")
1637+
parser.add_argument("--isl-version", type=int)
1638+
1639+
args = parser.parse_args()
1640+
1641+
gen_wrapper(args.include_dir,
1642+
output_dir=args.output_dir,
1643+
include_barvinok=args.barvinok,
1644+
isl_version=args.isl_version,
1645+
)
1646+
1647+
16191648
if __name__ == "__main__":
1620-
from os.path import expanduser
1621-
gen_wrapper([expanduser("isl/include")])
1649+
main()
16221650

16231651
# vim: foldmethod=marker

islpy/version.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
VERSION = (2025, 1, 5)
2-
VERSION_TEXT = ".".join(str(i) for i in VERSION)
1+
from __future__ import annotations
2+
3+
import re
4+
from importlib import metadata
5+
6+
7+
VERSION_TEXT = metadata.version("islpy")
8+
_match = re.match(r"^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
9+
assert _match is not None
10+
VERSION_STATUS = _match.group(2)
11+
VERSION = tuple(int(nr) for nr in _match.group(1).split("."))

pyproject.toml

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
11
[build-system]
2+
build-backend = "scikit_build_core.build"
23
requires = [
3-
# setuptools >= 64 breaks editable builds:
4-
# https://github.com/scikit-build/scikit-build/pull/737#issuecomment-1215573830
5-
# setuptools < 64 is incompatible with Python 3.12.
6-
# So: no editable builds on Python 3.12, for now.
7-
"setuptools>=42,<64;python_version<'3.12'",
8-
"setuptools>=64;python_version>='3.12'",
9-
10-
"wheel>=0.34.2",
11-
"scikit-build",
12-
"nanobind>=1.3",
4+
"scikit-build-core >=0.9.3",
5+
"nanobind >=1.9.2",
136
"pcpp",
7+
]
8+
9+
[project]
10+
name = "islpy"
11+
version = "2025.2"
12+
description = "Wrapper around isl, an integer set library"
13+
readme = "README.rst"
14+
license = "MIT"
15+
authors = [
16+
{ name = "Andreas Kloeckner", email = "[email protected]" },
17+
]
18+
requires-python = "~=3.10"
19+
20+
classifiers = [
21+
"Development Status :: 4 - Beta",
22+
"Intended Audience :: Developers",
23+
"Intended Audience :: Other Audience",
24+
"Intended Audience :: Science/Research",
25+
"Programming Language :: C++",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3",
28+
"Topic :: Scientific/Engineering",
29+
"Topic :: Scientific/Engineering :: Mathematics",
30+
"Topic :: Scientific/Engineering :: Physics",
31+
"Topic :: Scientific/Engineering :: Visualization",
32+
"Topic :: Software Development :: Libraries",
33+
]
1434

15-
# Added dynamically in setup.py if needed
16-
# "cmake>=3.18",
17-
# "ninja",
35+
[project.urls]
36+
Documentation = "https://documen.tician.de/islpy"
37+
Repository = "https://github.com/inducer/islpy"
38+
39+
40+
[dependency-groups]
41+
dev = [
42+
"pytest>=2",
1843
]
19-
build-backend = "setuptools.build_meta"
2044

2145
[tool.inducer-ci-support]
2246
disable-editable-pip-install = true
2347

48+
[tool.scikit-build]
49+
sdist.exclude = [
50+
".github",
51+
"run-*.sh",
52+
]
53+
2454
[tool.ruff]
2555
preview = true
2656
exclude = [

0 commit comments

Comments
 (0)