Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to scikit-build-core #397

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12...3.29)
cmake_minimum_required(VERSION 3.15...3.30)

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
30 changes: 0 additions & 30 deletions MANIFEST.in

This file was deleted.

98 changes: 0 additions & 98 deletions _custom_build/backend.py

This file was deleted.

84 changes: 80 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,87 @@
[build-system]
requires = [
"setuptools>=42",
"scikit-build~=0.18.0",
"scikit-build-core>=0.10.1",
"Cython >=3.0.11, <3.1.0"
]
build-backend = "backend"
backend-path = ["_custom_build"]
build-backend = "scikit_build_core.build"

[project]
name = "RapidFuzz"
dynamic = ["version"]
requires-python = ">= 3.9"
authors = [
{name = "Max Bachmann", email = "[email protected]"},
]
description = "rapid fuzzy string matching"
readme = "README.md"
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
maxbachmann marked this conversation as resolved.
Show resolved Hide resolved
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: MIT License",
]
Homepage = "https://github.com/rapidfuzz/RapidFuzz"
Documentation = "https://rapidfuzz.github.io/RapidFuzz/"
Repository = "https://github.com/rapidfuzz/RapidFuzz.git"
Issues = "https://github.com/rapidfuzz/RapidFuzz/issues"
Changelog = "https://github.com/rapidfuzz/RapidFuzz/blob/main/CHANGELOG.rst"

[project.optional-dependencies]
all = [
"numpy"
]

[project.entry-points.pyinstaller40]
hook-dirs = "rapidfuzz.__pyinstaller:get_hook_dirs"
tests = "rapidfuzz.__pyinstaller:get_PyInstaller_tests"

[tool.scikit-build]
maxbachmann marked this conversation as resolved.
Show resolved Hide resolved
minimum-version = "build-system.requires"
sdist.include = [
"src/rapidfuzz/*.cxx",
maxbachmann marked this conversation as resolved.
Show resolved Hide resolved
"src/rapidfuzz/distance/*.cxx",
]
sdist.exclude = [
".github"
]
wheel.exclude = [
"**.pyx",
"**.cxx",
"**.pxd",
"**.cpp",
"**.hpp",
"**.h",
"CMakeLists.txt",
"generate.sh"
]
wheel.packages = ["src/rapidfuzz"]
wheel.cmake = false

[[tool.scikit-build.overrides]]
if.any.system-cmake = ">=3.15"
if.any.cmake-wheel = true
wheel.cmake = true

[[tool.scikit-build.overrides]]
if.failed = true
wheel.cmake = false
messages.after-success = "failed to build C++ Extension, falling back to pure Python Extension"

[[tool.scikit-build.overrides]]
if.any.env.CIBUILDWHEEL = true
if.any.env.CONDA_BUILD = true
if.any.env.PIWHEELS_BUILD = true
if.any.env.RAPIDFUZZ_BUILD_EXTENSION = true
wheel.cmake = true
messages.after-failure = "failed to build C++ Extension in a packaged build"

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "src/rapidfuzz/__init__.py"


[tool.black]
line-length = 120
Expand Down
87 changes: 0 additions & 87 deletions setup.py

This file was deleted.

28 changes: 16 additions & 12 deletions src/rapidfuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ function(create_cython_target _name)
${CMAKE_CURRENT_LIST_DIR}/${_name}.cxx
PARENT_SCOPE)
else()
find_package(Cython REQUIRED)
# should use target_include_directories once this is supported by
# scikit-build
include_directories(${RF_BASE_DIR}/rapidfuzz)
add_cython_target(${_name} CXX)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}.cxx"
MAIN_DEPENDENCY "${CMAKE_CURRENT_LIST_DIR}/${_name}.pyx"
VERBATIM
COMMAND
Python::Interpreter -m cython "${CMAKE_CURRENT_LIST_DIR}/${_name}.pyx"
--cplus -I "${CMAKE_CURRENT_LIST_DIR}"
--output-file "${CMAKE_CURRENT_BINARY_DIR}/${_name}.cxx")

set(${_name}
${_name}
${CMAKE_CURRENT_BINARY_DIR}/${_name}.cxx
PARENT_SCOPE)
endif()
endfunction(create_cython_target)
Expand Down Expand Up @@ -39,22 +43,22 @@ if(RAPIDFUZZ_ARCH_X64 OR RAPIDFUZZ_ARCH_X86)
target_include_directories(_feature_detector_cpp
PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(_feature_detector_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS _feature_detector_cpp LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS _feature_detector_cpp DESTINATION rapidfuzz)
endif()

create_cython_target(utils_cpp)
rf_add_library(utils_cpp ${utils_cpp} ${CMAKE_CURRENT_LIST_DIR}/utils.cpp)
target_compile_features(utils_cpp PUBLIC cxx_std_17)
target_include_directories(utils_cpp PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(utils_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS utils_cpp LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS utils_cpp DESTINATION rapidfuzz)

create_cython_target(fuzz_cpp)
rf_add_library(fuzz_cpp ${fuzz_cpp})
target_compile_features(fuzz_cpp PUBLIC cxx_std_17)
target_include_directories(fuzz_cpp PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(fuzz_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS fuzz_cpp DESTINATION rapidfuzz)

if(RAPIDFUZZ_ARCH_X64 OR RAPIDFUZZ_ARCH_X86)
# on macOs this generates illegal instructions
Expand All @@ -72,7 +76,7 @@ if(RAPIDFUZZ_ARCH_X64 OR RAPIDFUZZ_ARCH_X86)

target_include_directories(fuzz_cpp_avx2 PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(fuzz_cpp_avx2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp_avx2 LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS fuzz_cpp_avx2 DESTINATION rapidfuzz)
endif()
endif()

Expand All @@ -89,7 +93,7 @@ if(RAPIDFUZZ_ARCH_X86)

target_include_directories(fuzz_cpp_sse2 PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(fuzz_cpp_sse2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp_sse2 LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS fuzz_cpp_sse2 DESTINATION rapidfuzz)
endif()

create_cython_target(process_cpp_impl)
Expand Down Expand Up @@ -185,4 +189,4 @@ if(NOT Windows)
endif()
endif()

install(TARGETS process_cpp_impl LIBRARY DESTINATION src/rapidfuzz)
install(TARGETS process_cpp_impl DESTINATION rapidfuzz)
Loading
Loading