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

use scikit-build-core #67

Closed
wants to merge 6 commits into from
Closed
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 .github/workflows/pythonbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ jobs:
name: artifact
path: dist

- uses: pypa/[email protected]
- uses: pypa/[email protected]
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
23 changes: 14 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
#
# See https://github.com/pre-commit/pre-commit

exclude: |
(?x)(
.*\.patch
)

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v4.6.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -32,26 +37,26 @@ repos:

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: "24.1.1" # Keep in sync with blacken-docs
rev: "24.4.2" # Keep in sync with blacken-docs
hooks:
- id: black

# Also code format the docs
- repo: https://github.com/asottile/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.8.0 # keep in sync with black hook

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: "v1.5.4"
rev: "v1.5.5"
hooks:
- id: remove-tabs

- repo: https://github.com/sirosen/texthooks
rev: "0.6.4"
rev: "0.6.6"
hooks:
- id: fix-ligatures
- id: fix-smartquotes
Expand All @@ -68,7 +73,7 @@ repos:

# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
rev: "v3.0.3"
rev: "v3.2.5"
hooks:
- id: pylint
files: ^pybind11
Expand Down Expand Up @@ -101,14 +106,14 @@ repos:
additional_dependencies: [cmake, ninja]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.2.1
rev: v0.5.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

# Check for spelling
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell
exclude: ".*/test_.*.py"
Expand All @@ -131,7 +136,7 @@ repos:

# Clang format the codebase automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v17.0.6"
rev: "v18.1.8"
hooks:
- id: clang-format
types_or: [c++, c]
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.30)

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.

53 changes: 49 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"
]
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"
regex = "(?i)^__version__: str = (\")(?P<value>.+?)\\1"

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

This file was deleted.

14 changes: 10 additions & 4 deletions src/Levenshtein/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ 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 +41,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/)
2 changes: 1 addition & 1 deletion src/Levenshtein/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from typing import overload
from collections.abc import Callable, Hashable, Sequence
from typing import overload

__author__: str
__license__: str
Expand Down
13 changes: 6 additions & 7 deletions tools/sdist.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
diff --git a/pyproject.toml b/pyproject.toml
index 27f4629..752d509 100644
index 0a8c033..cf967b9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,8 +1,7 @@
@@ -1,7 +1,6 @@
[build-system]
requires = [
"setuptools",
- "scikit-build>=0.13.0",
- "scikit-build-core>=0.9.8",
- "Cython>=3.0.2,<3.1.0"
+ "scikit-build>=0.13.0"
+ "scikit-build-core>=0.9.8"
]
build-backend = "backend"
backend-path = ["_custom_build"]
build-backend = "scikit_build_core.build"

Loading