Skip to content

Commit

Permalink
apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Feb 11, 2024
1 parent f98c043 commit d903316
Show file tree
Hide file tree
Showing 30 changed files with 174 additions and 174 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AccessModifierOffset: -4
AllowShortIfStatementsOnASingleLine: true
PointerAlignment: Left
AllowShortBlocksOnASingleLine: Always
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: None
BreakBeforeBraces: Custom
Expand All @@ -27,4 +26,4 @@ BraceWrapping:
AllowAllConstructorInitializersOnNextLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AllowShortCaseLabelsOnASingleLine: true
IndentPPDirectives: AfterHash
IndentPPDirectives: AfterHash
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/c_levenshtein.c linguist-vendored
src/c_levenshtein.c linguist-vendored
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github: maxbachmann
custom: ["https://www.paypal.com/donate/?hosted_button_id=VGWQBBD5CTWJU"]
custom: ["https://www.paypal.com/donate/?hosted_button_id=VGWQBBD5CTWJU"]
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/html
publish_dir: ./build/html
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ cython_debug/

# vscode
.vscode/
_skbuild/
_skbuild/
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ repos:
hooks:
- id: codespell
exclude: ".*/test_.*.py"
args: ["-x", ".codespell-ignore-lines"]
#args: ["-x", ".codespell-ignore-lines"]

# Check for common shell mistakes
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.2"
hooks:
- id: shellcheck
#- repo: https://github.com/shellcheck-py/shellcheck-py
# rev: "v0.9.0.6"
# hooks:
# - id: shellcheck

# Disallow some common capitalization mistakes
- repo: local
Expand Down
60 changes: 35 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,58 @@ set(SKBUILD_LINK_LIBRARIES_KEYWORD PRIVATE)
set(Python_FIND_IMPLEMENTATIONS CPython PyPy)

set(THREADS_PREFER_PTHREAD_FLAG ON)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET
"10.9"
CACHE STRING "Minimum OS X deployment version")
endif()

project(Levenshtein LANGUAGES C CXX)

if (MSVC)
add_compile_options(/W4)
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -pedantic)
add_compile_options(-Wall -Wextra -pedantic)
endif()

if(CMAKE_VERSION VERSION_LESS 3.18)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(
Python
COMPONENTS Interpreter Development
REQUIRED)
else()
set(Python_ARTIFACTS_INTERACTIVE TRUE)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
set(Python_ARTIFACTS_INTERACTIVE TRUE)
find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)
endif()

if(CMAKE_VERSION VERSION_LESS 3.17)
execute_process(
COMMAND "${Python_EXECUTABLE}" -c
"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX').split('.')[1])"
OUTPUT_VARIABLE Python_SOABI
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
message(STATUS "Corrected SOABI: ${Python_SOABI}")
execute_process(
COMMAND
"${Python_EXECUTABLE}" -c
"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX').split('.')[1])"
OUTPUT_VARIABLE Python_SOABI
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
message(STATUS "Corrected SOABI: ${Python_SOABI}")
elseif("${Python_INTERPRETER_ID}" STREQUAL "PyPy")
message(STATUS "PyPy SOABI: ${Python_SOABI}")
execute_process(
COMMAND "${Python_EXECUTABLE}" -c
"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX').split('.')[1])"
OUTPUT_VARIABLE Python_SOABI
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
message(STATUS "Corrected SOABI: ${Python_SOABI}")
message(STATUS "PyPy SOABI: ${Python_SOABI}")
execute_process(
COMMAND
"${Python_EXECUTABLE}" -c
"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX').split('.')[1])"
OUTPUT_VARIABLE Python_SOABI
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
message(STATUS "Corrected SOABI: ${Python_SOABI}")
endif()

find_package(rapidfuzz 3.0.0 QUIET)
if (rapidfuzz_FOUND)
message(STATUS "Using system supplied version of rapidfuzz-cpp")
if(rapidfuzz_FOUND)
message(STATUS "Using system supplied version of rapidfuzz-cpp")
else()
message(STATUS "Using packaged version of rapidfuzz-cpp")
add_subdirectory(extern/rapidfuzz-cpp)
message(STATUS "Using packaged version of rapidfuzz-cpp")
add_subdirectory(extern/rapidfuzz-cpp)
endif()

set(LEV_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Levenshtein)
Expand Down
10 changes: 5 additions & 5 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Expand Down Expand Up @@ -111,7 +111,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
Expand Down Expand Up @@ -169,7 +169,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
Expand Down Expand Up @@ -226,7 +226,7 @@ impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
Expand Down Expand Up @@ -279,7 +279,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

Appendix: How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
Expand Down
3 changes: 1 addition & 2 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,4 @@ v0.8.0
set was added

### v0.1.0
* Inital release

* Initial release
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>
<a href="https://github.com/rapidfuzz/Levenshtein/actions">
<img src="https://github.com/rapidfuzz/Levenshtein/workflows/Build/badge.svg"
alt="Continous Integration">
alt="Continuous Integration">
</a>
<a href="https://pypi.org/project/levenshtein/">
<img src="https://img.shields.io/pypi/v/levenshtein"
Expand Down
21 changes: 13 additions & 8 deletions _custom_build/backend.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from setuptools import build_meta as _orig
from __future__ import annotations

import platform as _platform
import subprocess as _subprocess

from packaging import version as _version
from packaging.tags import sys_tags as _sys_tags
from skbuild.exceptions import SKBuildError as _SKBuildError
from setuptools import build_meta as _orig
from skbuild.cmaker import get_cmake_version as _get_cmake_version
import subprocess as _subprocess
import platform as _platform
from skbuild.exceptions import SKBuildError as _SKBuildError

prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist


def _cmake_required():
try:
if _version.parse(_get_cmake_version()) >= _version.parse("3.12"):
Expand All @@ -21,26 +24,28 @@ def _cmake_required():

return True


def _ninja_required():
if _platform.system() == "Windows":
print("Ninja is part of the MSVC installation on Windows")
return False

for generator in ("ninja", "make"):
try:
_subprocess.check_output([generator, '--version'])
_subprocess.check_output([generator, "--version"])
print(f"Using System version of {generator}")
return False
except (OSError, _subprocess.CalledProcessError):
pass

return True


def get_requires_for_build_wheel(config_settings=None):
packages = []
if _cmake_required():
packages.append('cmake')
packages.append("cmake")
if _ninja_required():
packages.append('ninja')
packages.append("ninja")

return _orig.get_requires_for_build_wheel(config_settings) + packages
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.. include:: ../HISTORY.txt
.. include:: ../HISTORY.txt
21 changes: 10 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,24 @@


# -- Project information -----------------------------------------------------
from __future__ import annotations

project = 'Levenshtein'
copyright = '2021, Max Bachmann'
author = 'Max Bachmann'
project = "Levenshtein"
copyright = "2021, Max Bachmann"
author = "Max Bachmann"

# The full version, including alpha/beta/rc tags
release = '0.23.0'
release = "0.23.0"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.napoleon'
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -47,13 +46,13 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

napoleon_google_docstring = False

# -- Extension configuration -------------------------------------------------
# -- Extension configuration -------------------------------------------------
5 changes: 0 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.. RapidFuzz documentation master file, created by
sphinx-quickstart on Fri Jan 1 19:02:29 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Levenshtein's documentation!
=======================================

Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Installation
============

The recommended method to install Levenshtein is by using `pip` (the Python package manager)
The recommended method to install Levenshtein is by using ``pip`` (the Python package manager)

using pip
---------

Levenshtein can be installed with `pip`:
Levenshtein can be installed with ``pip``:

.. code-block:: sh
Expand Down
20 changes: 10 additions & 10 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pushd %~dp0
REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=docs
set BUILDDIR=build
Expand All @@ -14,15 +14,15 @@ if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extend-ignore = [
"E501", # Line too long
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
"PTH123", # use pathlib instead of builtin open
"PLC1901", # simply not always correct
]
target-version = "py38"
src = ["src"]
Expand Down
Loading

0 comments on commit d903316

Please sign in to comment.