diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7a619ba --- /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_compile_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..7953c9e 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/fbitset/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/*']}, -)