Skip to content

Commit

Permalink
use scikit-build-core
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Jul 13, 2024
1 parent 431c03d commit 2e3444d
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 109 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ cython_debug/
# vscode
.vscode/
_skbuild/

# Cython generated files
*.cxx
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.24)
cmake_minimum_required(VERSION 3.15...3.26)

cmake_policy(SET CMP0054 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
Expand Down
16 changes: 0 additions & 16 deletions MANIFEST.in

This file was deleted.

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

This file was deleted.

69 changes: 65 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
[build-system]
requires = [
"setuptools",
"scikit-build>=0.13.0",
"scikit-build-core>=0.9.8",
"Cython>=3.0.2,<3.1.0"
]
build-backend = "backend"
backend-path = ["_custom_build"]
build-backend = "scikit_build_core.build"

[project]
name = "Levenshtein"
dynamic = ["version"]
dependencies = [
"rapidfuzz >= 3.8.0, < 4.0.0"
]
requires-python = ">= 3.8"
authors = [
{name = "Max Bachmann", email = "[email protected]"},
]
description = "Python extension for computing string edit distances and similarities."
readme = "README.md"
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
]
Homepage = "https://github.com/rapidfuzz/Levenshtein"
Documentation = "https://rapidfuzz.github.io/Levenshtein/"
Repository = "https://github.com/rapidfuzz/Levenshtein.git"
Issues = "https://github.com/rapidfuzz/Levenshtein/issues"
Changelog = "https://github.com/rapidfuzz/Levenshtein/blob/main/HISTORY.md"

[tool.scikit-build]
sdist.include = [
"src/Levenshtein/*.cxx",
"src/Levenshtein/_version.py"
]
sdist.exclude = [
".github"
]
wheel.exclude = [
"**.pyx",
"**.cxx",
"**.cpp",
"**.hpp",
"CMakeLists.txt",
"generate.sh"
]

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

[tool.black]
line-length = 120
Expand Down Expand Up @@ -95,3 +140,19 @@ isort.required-imports = ["from __future__ import annotations"]
"bench/**" = ["T20"]
"_custom_build/backend.py" = ["T20"]
"setup.py" = ["T20"]




#[tool.scikit-build]



#setup(
# url="https://github.com/rapidfuzz/Levenshtein",
# license="GPL",
# license_file="COPYING",
# packages=["Levenshtein"],
# package_dir={"": "src"},
# package_data={"Levenshtein": ["*.pyi", "py.typed"]},
#)
33 changes: 0 additions & 33 deletions setup.py

This file was deleted.

15 changes: 11 additions & 4 deletions src/Levenshtein/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ function(create_cython_target _name)
${CMAKE_CURRENT_LIST_DIR}/${_name}.cxx
PARENT_SCOPE)
else()
find_package(Cython REQUIRED)
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" --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 @@ -35,4 +42,4 @@ target_compile_features(levenshtein_cpp PUBLIC cxx_std_17)
target_include_directories(levenshtein_cpp
PRIVATE ${LEV_BASE_DIR}/Levenshtein-c)
target_link_libraries(levenshtein_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS levenshtein_cpp LIBRARY DESTINATION src/Levenshtein)
install(TARGETS levenshtein_cpp DESTINATION Levenshtein/)

0 comments on commit 2e3444d

Please sign in to comment.