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

[FindPython] Work around PyPy bug #13

Merged
merged 17 commits into from
Sep 22, 2022
Merged
4 changes: 2 additions & 2 deletions .github/workflows/branchbuild.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Test Build

on:
push:
Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
pip install build; python -m build --sdist
# test whether tarball contains all files required for compiling
pip install dist/jarowinkler-*.tar.gz
pip install dist/jarowinkler-*.tar.gz -v

- name: Test type stubs
run: |
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/releasebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
git apply ./tools/sdist.patch
pip install build; python -m build --sdist
# test whether tarball contains all files required for compiling
pip install dist/jarowinkler-*.tar.gz
pip install dist/jarowinkler-*.tar.gz -vvv

- name: Test type stubs
run: |
Expand Down Expand Up @@ -71,14 +71,6 @@ jobs:
python_tag: "pp38-*"
- arch: auto32
python_tag: "pp39-*"

# PyPy Windows is currently broken in scikit-build
- arch: auto64
python_tag: "pp37-*"
- arch: auto64
python_tag: "pp38-*"
- arch: auto64
python_tag: "pp39-*"
env:
CIBW_BUILD: ${{matrix.python_tag}}
CIBW_ARCHS: ${{matrix.arch}}
Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)

project(jarowinkler LANGUAGES C CXX)

find_package(PythonExtensions REQUIRED)
if(CMAKE_VERSION VERSION_LESS 3.18)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
else()
set(Python_ARTIFACTS_INTERACTIVE TRUE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required but simpler.

find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
endif()

if("${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}")
endif()

include(FetchContent)

set(JW_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"scikit-build>=0.13.0",
"scikit-build @ git+https://github.com/scikit-build/scikit-build@master",
"Cython==3.0.0a11",
"rapidfuzz_capi==1.0.5"
]
Expand Down
3 changes: 1 addition & 2 deletions src/jarowinkler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ function(create_cython_target _name)
endfunction(create_cython_target)

create_cython_target(_initialize_cpp)
add_library(_initialize_cpp MODULE ${_initialize_cpp})
Python_add_library(_initialize_cpp MODULE WITH_SOABI ${_initialize_cpp})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only PyPy seems to care if this is missing. Maybe to avoid reading a CPython .so?

target_compile_features(_initialize_cpp PUBLIC cxx_std_14)
target_include_directories(_initialize_cpp PRIVATE ${RF_CAPI_PATH} ${JW_BASE_DIR}/jarowinkler)
target_link_libraries(_initialize_cpp PRIVATE jaro_winkler::jaro_winkler)
python_extension_module(_initialize_cpp)
install(TARGETS _initialize_cpp LIBRARY DESTINATION src/jarowinkler)
2 changes: 1 addition & 1 deletion tools/sdist.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ index 1f4d4d6..1f94979 100644
@@ -2,7 +2,6 @@
requires = [
"setuptools>=42",
"scikit-build>=0.13.0",
"scikit-build @ git+https://github.com/scikit-build/scikit-build@master",
- "Cython==3.0.0a11",
"rapidfuzz_capi==1.0.5"
]
Expand Down