From 048a395bb77f348c3243cb491f252d0e3fb41f97 Mon Sep 17 00:00:00 2001 From: Gaurav Harsha Date: Thu, 13 Nov 2025 01:03:31 -0500 Subject: [PATCH 1/3] migrate to scikit build system --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 17 +++++++++-------- setup.py | 41 ----------------------------------------- 3 files changed, 45 insertions(+), 49 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 setup.py diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d261e17 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.15) +project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX) + +# Set C++ standard +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Find Python +find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) + +# Include directories +set(CPYPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/cpypp/include") +set(FBITSET_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/fbitset/include") +set(LIBPARENTH_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/libparenth/include") + +# Platform-specific compiler flags +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + message(STATUS "Configuring for macOS (Darwin)") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") + add_compiler_options(-stdlib=libc++) +# elseif(MSVC) +# # MSVC compiler flags +# add_compile_options(/EHsc /bigobj /wd4996 /wd4267 /Zc:twoPhase-) +endif() + +# parenth extension +Python_add_library(_parenth MODULE + gristmill/_parenth.cpp + WITH_SOABI +) +target_include_directories(_parenth PRIVATE + ${CPYPP_INCLUDE_DIR} + ${FBITSET_INCLUDE_DIR} + ${LIBPARENTH_INCLUDE_DIR} +) +install(TARGETS _parenth LIBRARY DESTINATION gristmill) diff --git a/pyproject.toml b/pyproject.toml index d095700..c8744d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,13 @@ [build-system] -requires = ["setuptools>=77", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["scikit-build-core>=0.10"] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] +cmake.minimum-version = "3.15" # Minimum version of CMake +cmake.verbose = true # Verbose build for debugging +# Don't create a separate subdirectory - install alongside Python source files +wheel.packages = ["gristmill"] +sdist.include = ["gristmill/templates/*", "deps/cpypp/include/*.hpp", "deps/fbind/include/*.hpp", "deps/libparenth/include/*.hpp"] [project] name = "gristmill" @@ -40,9 +47,3 @@ dev = ["pytest", "juliacall>=0.9.20"] [project.urls] Homepage = "https://github.com/DrudgeCAS/gristmill" - -[tool.setuptools] -include-package-data = true - -[tool.setuptools.package-data] -gristmill = ["templates/*"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 080479c..0000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Setup script for gristmill.""" - -import os.path -import sys -from setuptools import setup, find_packages, Extension - - -PROJ_ROOT = os.path.dirname(os.path.abspath(__file__)) -INCLUDE_DIRS = [ - os.path.join(PROJ_ROOT, 'deps', i, 'include') - for i in ['cpypp', 'fbitset', 'libparenth'] -] - -# Platform-specific compiler flags -if sys.platform == "win32": - # MSVC compiler flags - COMPILE_FLAGS = ['/std:c++20'] -else: - # GCC/Clang compiler flags - COMPILE_FLAGS = ['-std=c++20'] - - # Additional flags for macOS to avoid header conflicts - if sys.platform == "darwin": - # Use libc++ standard library explicitly on macOS - COMPILE_FLAGS.extend([ - '-stdlib=libc++', - '-mmacosx-version-min=10.9' - ]) - -parenth = Extension( - 'gristmill._parenth', - ['gristmill/_parenth.cpp'], - include_dirs=INCLUDE_DIRS, - extra_compile_args=COMPILE_FLAGS -) - -setup( - packages=find_packages(), - ext_modules=[parenth], - package_data={'gristmill': ['templates/*']}, -) From 0e44c7e8ae75f35718c53e450201b496e697d0f7 Mon Sep 17 00:00:00 2001 From: Gaurav Harsha Date: Thu, 13 Nov 2025 01:06:36 -0500 Subject: [PATCH 2/3] fix typo in CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d261e17..7a619ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(LIBPARENTH_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/libparenth/include" if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") message(STATUS "Configuring for macOS (Darwin)") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") - add_compiler_options(-stdlib=libc++) + add_compile_options(-stdlib=libc++) # elseif(MSVC) # # MSVC compiler flags # add_compile_options(/EHsc /bigobj /wd4996 /wd4267 /Zc:twoPhase-) From c2c558c7b15ae9261402c0dcca639815c5c4723a Mon Sep 17 00:00:00 2001 From: Gaurav Harsha Date: Thu, 13 Nov 2025 01:14:16 -0500 Subject: [PATCH 3/3] Update pyproject.toml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c8744d6..7953c9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ cmake.minimum-version = "3.15" # Minimum version of CMake cmake.verbose = true # Verbose build for debugging # Don't create a separate subdirectory - install alongside Python source files wheel.packages = ["gristmill"] -sdist.include = ["gristmill/templates/*", "deps/cpypp/include/*.hpp", "deps/fbind/include/*.hpp", "deps/libparenth/include/*.hpp"] +sdist.include = ["gristmill/templates/*", "deps/cpypp/include/**/*.hpp", "deps/fbitset/include/**/*.hpp", "deps/libparenth/include/**/*.hpp"] [project] name = "gristmill"