Skip to content

Commit 24255ac

Browse files
authored
Use scikit_build_core (#751)
Move away from setuptools and use scikit_build_core to build instead
1 parent 77d597b commit 24255ac

7 files changed

Lines changed: 63 additions & 93 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
cmake_minimum_required(VERSION 3.17.0)
1+
cmake_minimum_required(VERSION 3.21...4.0)
22

33
project(implicit)
44

5+
find_package(
6+
Python
7+
COMPONENTS Interpreter Development.Module
8+
REQUIRED)
9+
include(UseCython)
10+
511
enable_testing()
612

7-
find_package(PythonExtensions REQUIRED)
8-
find_package(Cython REQUIRED)
913
find_package(OpenMP)
1014

1115
include_directories(.)

ci/install_cuda_13.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ dnf install -y \
44
cuda-nvcc-13-0 \
55
cuda-cudart-devel-13-0 \
66
libcurand-devel-13-0 \
7-
libcublas-devel-13-0 \
8-
ninja-build
7+
libcublas-devel-13-0
98

109
ln -s cuda-13.0 /usr/local/cuda

implicit/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ if(NOT CYTHON_FLAGS)
44
)
55
endif()
66

7-
add_cython_target(_nearest_neighbours CXX)
8-
add_library(_nearest_neighbours MODULE ${_nearest_neighbours})
9-
python_extension_module(_nearest_neighbours)
7+
cython_transpile(_nearest_neighbours.pyx LANGUAGE CXX)
8+
python_add_library(_nearest_neighbours MODULE _nearest_neighbours.cxx)
109
install(TARGETS _nearest_neighbours LIBRARY DESTINATION implicit)
1110

12-
add_cython_target(evaluation CXX)
13-
add_library(evaluation MODULE ${evaluation})
14-
python_extension_module(evaluation)
11+
cython_transpile(evaluation.pyx LANGUAGE CXX)
12+
python_add_library(evaluation MODULE evaluation.cxx)
1513
install(TARGETS evaluation LIBRARY DESTINATION implicit)
1614

1715
if(OpenMP_CXX_FOUND)
18-
target_link_libraries(_nearest_neighbours OpenMP::OpenMP_CXX)
19-
target_link_libraries(evaluation OpenMP::OpenMP_CXX)
16+
target_link_libraries(_nearest_neighbours PUBLIC OpenMP::OpenMP_CXX)
17+
target_link_libraries(evaluation PUBLIC OpenMP::OpenMP_CXX)
2018
endif()
2119

2220
add_subdirectory(cpu)

implicit/cpu/CMakeLists.txt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
add_cython_target(_als CXX)
2-
add_library(_als MODULE ${_als})
3-
python_extension_module(_als)
1+
cython_transpile(_als.pyx LANGUAGE CXX)
2+
python_add_library(_als MODULE _als.cxx)
43
install(TARGETS _als LIBRARY DESTINATION implicit/cpu)
54

6-
add_cython_target(bpr CXX)
7-
add_library(bpr MODULE ${bpr})
8-
python_extension_module(bpr)
5+
cython_transpile(bpr.pyx LANGUAGE CXX)
6+
python_add_library(bpr MODULE bpr.cxx)
97
install(TARGETS bpr LIBRARY DESTINATION implicit/cpu)
108

11-
add_cython_target(topk CXX)
12-
add_library(topk MODULE ${topk})
13-
python_extension_module(topk)
9+
cython_transpile(topk.pyx LANGUAGE CXX)
10+
python_add_library(topk MODULE topk.cxx)
1411
install(TARGETS topk LIBRARY DESTINATION implicit/cpu)
1512

16-
add_cython_target(lmf CXX)
17-
add_library(lmf MODULE ${lmf})
18-
python_extension_module(lmf)
13+
cython_transpile(lmf.pyx LANGUAGE CXX)
14+
python_add_library(lmf MODULE lmf.cxx)
1915
install(TARGETS lmf LIBRARY DESTINATION implicit/cpu)
2016

2117
if(OpenMP_CXX_FOUND)
22-
target_link_libraries(_als OpenMP::OpenMP_CXX)
23-
target_link_libraries(bpr OpenMP::OpenMP_CXX)
24-
target_link_libraries(topk OpenMP::OpenMP_CXX)
25-
target_link_libraries(lmf OpenMP::OpenMP_CXX)
18+
target_link_libraries(_als PUBLIC OpenMP::OpenMP_CXX)
19+
target_link_libraries(bpr PUBLIC OpenMP::OpenMP_CXX)
20+
target_link_libraries(topk PUBLIC OpenMP::OpenMP_CXX)
21+
target_link_libraries(lmf PUBLIC OpenMP::OpenMP_CXX)
2622
endif()
2723

2824
FILE(GLOB cpu_python_files *.py)

implicit/gpu/CMakeLists.txt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ elseif(DEFINED ENV{IMPLICIT_DISABLE_CUDA})
1111

1212
else()
1313
enable_language(CUDA)
14-
add_cython_target(_cuda CXX)
14+
cython_transpile(_cuda.pyx LANGUAGE CXX)
1515

1616
add_compile_options(-DCCCL_IGNORE_DEPRECATED_STREAM_REF_HEADER)
1717

@@ -31,16 +31,14 @@ else()
3131

3232
# We must find CCCL ourselves before raft so that we get the right version.
3333
include(${rapids-cmake-dir}/cpm/cccl.cmake)
34-
rapids_cpm_cccl(BUILD_EXPORT_SET implicit-exports INSTALL_EXPORT_SET implicit-exports)
34+
rapids_cpm_cccl()
3535

3636
# get rmm
3737
include(${rapids-cmake-dir}/cpm/rmm.cmake)
38-
rapids_cpm_rmm(BUILD_EXPORT_SET implicit-exports INSTALL_EXPORT_SET implicit-exports)
38+
rapids_cpm_rmm()
3939

4040
rapids_cpm_find(raft 26.02
4141
GLOBAL_TARGETS raft::raft
42-
BUILD_EXPORT_SET implicit-exports
43-
INSTALL_EXPORT_SET implicit-exports
4442
CPM_ARGS
4543
GIT_REPOSITORY https://github.com/rapidsai/raft.git
4644
GIT_TAG v26.02.00
@@ -52,16 +50,14 @@ else()
5250
)
5351
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda -Wno-deprecated-gpu-targets -Xfatbin=-compress-all --expt-relaxed-constexpr")
5452

55-
add_library(_cuda MODULE ${_cuda}
53+
python_add_library(_cuda MODULE _cuda.cxx
5654
als.cu
5755
bpr.cu
5856
matrix.cu
5957
random.cu
6058
knn.cu
6159
)
6260

63-
python_extension_module(_cuda)
64-
6561
if(DEFINED ENV{IMPLICIT_CUDA_ARCH})
6662
message("using cuda arch $ENV{IMPLICIT_CUDA_ARCH}")
6763
set_target_properties(_cuda PROPERTIES CUDA_ARCHITECTURES $ENV{IMPLICIT_CUDA_ARCH})
@@ -78,7 +74,7 @@ else()
7874
get_target_property(CUDA_ARCH _cuda CUDA_ARCHITECTURES)
7975
message("using cuda architectures ${CUDA_ARCH} for cuda version ${CUDAToolkit_VERSION}")
8076
endif()
81-
target_link_libraries(_cuda CUDA::cublas CUDA::curand rmm::rmm raft::raft)
77+
target_link_libraries(_cuda PRIVATE CUDA::cublas CUDA::curand raft::raft)
8278

8379
install(TARGETS _cuda LIBRARY DESTINATION implicit/gpu)
8480
endif()

pyproject.toml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
11
[build-system]
22
requires = [
3-
"setuptools>=42",
43
"wheel",
5-
"scikit-build>=0.13.1",
6-
"Cython>=0.24",
4+
"scikit-build-core>=0.11",
5+
"cython",
6+
"cython-cmake",
77
"scipy>=0.16",
8-
"cmake>=3.18",
9-
"ninja"
108
]
11-
build-backend = "setuptools.build_meta"
9+
build-backend = "scikit_build_core.build"
10+
11+
[project]
12+
name = "implicit"
13+
version = "0.7.2"
14+
description = "Collaborative Filtering for Implicit Feedback Datasets"
15+
readme = "README.md"
16+
authors = [
17+
{ name = "Ben Frederickson", email = "ben@benfrederickson.com" },
18+
]
19+
requires-python = ">=3.8"
20+
license = "MIT"
21+
license-files = ["LICENSE"]
22+
classifiers = [
23+
"Development Status :: 4 - Beta",
24+
"Natural Language :: English",
25+
"Intended Audience :: Science/Research",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Cython",
29+
"Operating System :: OS Independent",
30+
"Topic :: Software Development :: Libraries :: Python Modules",
31+
]
32+
dependencies = ["numpy>=1.17.0", "scipy>=0.16", "tqdm>=4.27", "threadpoolctl"]
33+
34+
[tool.scikit-build]
35+
wheel.exclude = ["**.pyx", "**.cmake", "**.cuh", "**.hpp", "**.h", "**.hpp.in"]
36+
cmake.version = ">=3.21.0"
37+
ninja.version = ">=1.10"
1238

1339
[tool.cibuildwheel]
1440
# skip testing in the cibuildwheel phase, will install the wheels later

setup.py

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

0 commit comments

Comments
 (0)