Skip to content

Commit 0646432

Browse files
Transurgeonclaude
andcommitted
migrate build system from setuptools to scikit-build-core
Replace the manual setup.py (which compiled ~49 C files with per-platform BLAS logic and Windows workarounds) with a top-level CMakeLists.txt that delegates to the submodule's existing CMake build. This eliminates the dense_matrix_stub.c, the #ifdef _MSC_VER guards in bindings.c, and enables dense matmul support on Windows via vcpkg OpenBLAS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f07a23c commit 0646432

6 files changed

Lines changed: 36 additions & 127 deletions

File tree

.github/workflows/build-and-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
CIBW_ARCHS_MACOS: "x86_64 universal2"
6666
CIBW_ARCHS_LINUX: "auto aarch64"
6767
CIBW_BEFORE_BUILD_LINUX: "yum install -y openblas-devel || apt-get install -y libopenblas-dev"
68+
CIBW_BEFORE_BUILD_WINDOWS: "vcpkg install openblas:x64-windows"
69+
CIBW_ENVIRONMENT_WINDOWS: "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
6870
- name: Check wheels
6971
shell: bash
7072
run: |

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(SparseDiffPy LANGUAGES C)
3+
4+
add_subdirectory(SparseDiffEngine)
5+
6+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module NumPy)
7+
8+
# Linux: CMake find_package(BLAS) doesn't set include dirs;
9+
# openblas puts cblas.h in /usr/include/openblas/
10+
if(UNIX AND NOT APPLE)
11+
find_path(OPENBLAS_INCLUDE_DIR cblas.h PATHS /usr/include/openblas /usr/include)
12+
if(OPENBLAS_INCLUDE_DIR)
13+
target_include_directories(dnlp_diff PRIVATE ${OPENBLAS_INCLUDE_DIR})
14+
endif()
15+
endif()
16+
17+
python3_add_library(_sparsediffengine MODULE
18+
sparsediffpy/_bindings/bindings.c
19+
)
20+
21+
target_include_directories(_sparsediffengine PRIVATE
22+
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include
23+
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/src
24+
${CMAKE_CURRENT_SOURCE_DIR}/sparsediffpy/_bindings
25+
)
26+
27+
target_link_libraries(_sparsediffengine PRIVATE dnlp_diff Python3::NumPy)
28+
29+
install(TARGETS _sparsediffengine DESTINATION sparsediffpy)

pyproject.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["numpy >= 2.0.0", "setuptools >= 68.1.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["scikit-build-core >= 0.10", "numpy >= 2.0.0"]
3+
build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "sparsediffpy"
@@ -14,8 +14,6 @@ license = "Apache-2.0"
1414
file = "README.md"
1515
content-type = "text/markdown"
1616

17-
[tool.setuptools]
18-
include-package-data = false
19-
20-
[tool.setuptools.packages.find]
21-
include = ["sparsediffpy*"]
17+
[tool.scikit-build]
18+
cmake.minimum-version = "3.15"
19+
wheel.packages = ["sparsediffpy"]

setup.py

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

sparsediffpy/_bindings/bindings.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#include "atoms/const_vector_mult.h"
1212
#include "atoms/constant.h"
1313
#include "atoms/cos.h"
14-
#ifndef _MSC_VER
1514
#include "atoms/dense_matmul.h"
16-
#endif
1715
#include "atoms/diag_vec.h"
1816
#include "atoms/entr.h"
1917
#include "atoms/exp.h"
@@ -114,16 +112,12 @@ static PyMethodDef DNLPMethods[] = {
114112
{"make_xexp", py_make_xexp, METH_VARARGS, "Create xexp node"},
115113
{"make_sparse_left_matmul", py_make_sparse_left_matmul, METH_VARARGS,
116114
"Create sparse left matmul node (A @ f(x))"},
117-
#ifndef _MSC_VER
118115
{"make_dense_left_matmul", py_make_dense_left_matmul, METH_VARARGS,
119116
"Create dense left matmul node (A @ f(x)) where A is dense"},
120-
#endif
121117
{"make_sparse_right_matmul", py_make_sparse_right_matmul, METH_VARARGS,
122118
"Create sparse right matmul node (f(x) @ A)"},
123-
#ifndef _MSC_VER
124119
{"make_dense_right_matmul", py_make_dense_right_matmul, METH_VARARGS,
125120
"Create dense right matmul node (f(x) @ A) where A is dense"},
126-
#endif
127121
{"make_quad_form", py_make_quad_form, METH_VARARGS,
128122
"Create quadratic form node (x' * Q * x)"},
129123
{"make_quad_over_lin", py_make_quad_over_lin, METH_VARARGS,

sparsediffpy/_bindings/dense_matrix_stub.c

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

0 commit comments

Comments
 (0)