From 6b6c3cd77a4ff49f5473ae21dfb4cfb31854c723 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 3 Sep 2022 09:20:26 +0200 Subject: [PATCH 01/15] use FindPython --- .github/workflows/releasebuild.yml | 3 +++ CMakeLists.txt | 3 +-- src/jarowinkler/CMakeLists.txt | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml index 4ea9705..58c0e87 100644 --- a/.github/workflows/releasebuild.yml +++ b/.github/workflows/releasebuild.yml @@ -4,10 +4,13 @@ on: push: branches: - main + - FindPython release: types: - published + workflow_dispatch: + jobs: build_wheels_windows: name: Build wheel on windows-latest/${{matrix.arch}}/${{matrix.python_tag}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 709c81f..f4b94b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,7 @@ endif() project(jarowinkler LANGUAGES C CXX) -find_package(PythonExtensions REQUIRED) -find_package(Python COMPONENTS Interpreter Development) +find_package(Python COMPONENTS Interpreter Development REQUIRED) include(FetchContent) set(JW_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) diff --git a/src/jarowinkler/CMakeLists.txt b/src/jarowinkler/CMakeLists.txt index 8caf71a..62f43c4 100644 --- a/src/jarowinkler/CMakeLists.txt +++ b/src/jarowinkler/CMakeLists.txt @@ -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 ${_initialize_cpp}) 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) From d10cf588f231325de11389adeb6db4f08caf8174 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 3 Sep 2022 09:34:56 +0200 Subject: [PATCH 02/15] build from sdist --- .github/workflows/branchbuild.yml | 2 +- .github/workflows/releasebuild.yml | 106 ++++++++++++++++------------- 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/.github/workflows/branchbuild.yml b/.github/workflows/branchbuild.yml index 4dae4b2..129c448 100644 --- a/.github/workflows/branchbuild.yml +++ b/.github/workflows/branchbuild.yml @@ -1,4 +1,4 @@ -name: Build +name: Test Build on: push: diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml index 58c0e87..0dcc896 100644 --- a/.github/workflows/releasebuild.yml +++ b/.github/workflows/releasebuild.yml @@ -1,4 +1,4 @@ -name: Build +name: Full Build on: push: @@ -12,8 +12,51 @@ on: workflow_dispatch: jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + + - uses: actions/setup-python@v2 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest hypothesis mypy rapidfuzz_capi Cython==3.0.0a11 + + # The cythonized files allow installation from the sdist without cython + - name: Generate cython + run: | + chmod +x ./src/jarowinkler/generate.sh + ./src/jarowinkler/generate.sh + + - name: Build sdist + run: | + 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 + + - name: Test type stubs + run: | + python -m mypy.stubtest jarowinkler --ignore-missing-stub + + - name: Test with pytest + run: | + pytest tests + python -m pytest tests + + - uses: actions/upload-artifact@v2 + with: + path: dist/*.tar.gz + + build_wheels_windows: name: Build wheel on windows-latest/${{matrix.arch}}/${{matrix.python_tag}} + needs: [build_sdist] runs-on: windows-latest strategy: fail-fast: false @@ -44,15 +87,17 @@ jobs: CIBW_BUILD_VERBOSITY: 3 steps: - - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 with: - submodules: 'true' + name: artifact + path: dist - uses: actions/setup-python@v2 - name: Build wheels uses: pypa/cibuildwheel@v2.9.0 with: + package-dir: dist/*.tar.gz output-dir: wheelhouse - name: Upload wheels @@ -62,6 +107,7 @@ jobs: build_wheels_macos: name: Build wheel on macos-latest/${{matrix.arch}}/${{matrix.python_tag}} + needs: [build_sdist] runs-on: macos-latest strategy: fail-fast: false @@ -101,15 +147,17 @@ jobs: CIBW_BUILD_VERBOSITY: 3 steps: - - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 with: - submodules: 'true' + name: artifact + path: dist - uses: actions/setup-python@v2 - name: Build wheels uses: pypa/cibuildwheel@v2.9.0 with: + package-dir: dist/*.tar.gz output-dir: wheelhouse - name: Upload wheels @@ -119,6 +167,7 @@ jobs: build_wheels_linux: name: Build wheels on ubuntu-latest/${{matrix.arch}}/${{matrix.python_tag}} + needs: [build_sdist] runs-on: ubuntu-latest strategy: fail-fast: false @@ -148,9 +197,10 @@ jobs: CIBW_BUILD_VERBOSITY: 3 steps: - - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 with: - submodules: 'true' + name: artifact + path: dist - uses: actions/setup-python@v2 @@ -160,6 +210,7 @@ jobs: - name: Build wheel uses: pypa/cibuildwheel@v2.9.0 with: + package-dir: dist/*.tar.gz output-dir: wheelhouse - name: Upload wheels @@ -167,47 +218,6 @@ jobs: with: path: ./wheelhouse/*.whl - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: 'true' - - - uses: actions/setup-python@v2 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest hypothesis mypy rapidfuzz_capi Cython==3.0.0a11 - - # The cythonized files allow installation from the sdist without cython - - name: Generate cython - run: | - chmod +x ./src/jarowinkler/generate.sh - ./src/jarowinkler/generate.sh - - - name: Build sdist - run: | - 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 - - - name: Test type stubs - run: | - python -m mypy.stubtest jarowinkler --ignore-missing-stub - - - name: Test with pytest - run: | - pytest tests - python -m pytest tests - - - uses: actions/upload-artifact@v2 - with: - path: dist/*.tar.gz - deploy-wheels: if: github.event_name == 'release' && github.event.action == 'published' needs: [build_wheels_windows, build_wheels_macos, build_wheels_linux, build_sdist] From ca9c59cf497b4e29d94f64fa5fea15b9c6953cc7 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 3 Sep 2022 16:04:13 +0200 Subject: [PATCH 03/15] fix patch --- tools/sdist.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sdist.patch b/tools/sdist.patch index 8213b82..2efccd1 100644 --- a/tools/sdist.patch +++ b/tools/sdist.patch @@ -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@henryiii-patch-1", - "Cython==3.0.0a11", "rapidfuzz_capi==1.0.5" ] From c200a9b8f273590b9a8b7bb85d92ce98fc26fe49 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 3 Sep 2022 16:25:21 +0200 Subject: [PATCH 04/15] enable pypy on Windows --- .github/workflows/releasebuild.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml index bc0299c..99792dc 100644 --- a/.github/workflows/releasebuild.yml +++ b/.github/workflows/releasebuild.yml @@ -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}} From 6c0e37f16d6aea923c03a9b26cea630484b61791 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 10 Sep 2022 00:48:02 +0200 Subject: [PATCH 05/15] update scikit-build to master --- pyproject.toml | 2 +- tools/sdist.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b226d0f..fe02060 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ "setuptools>=42", - "scikit-build @ git+https://github.com/scikit-build/scikit-build@henryiii-patch-1", + "scikit-build @ git+https://github.com/scikit-build/scikit-build@master", "Cython==3.0.0a11", "rapidfuzz_capi==1.0.5" ] diff --git a/tools/sdist.patch b/tools/sdist.patch index 2efccd1..77af08e 100644 --- a/tools/sdist.patch +++ b/tools/sdist.patch @@ -5,7 +5,7 @@ index 1f4d4d6..1f94979 100644 @@ -2,7 +2,6 @@ requires = [ "setuptools>=42", - "scikit-build @ git+https://github.com/scikit-build/scikit-build@henryiii-patch-1", + "scikit-build @ git+https://github.com/scikit-build/scikit-build@master", - "Cython==3.0.0a11", "rapidfuzz_capi==1.0.5" ] From 84fa385060e4e41c58aa75dfa1e46021b92e8370 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Sat, 10 Sep 2022 00:55:31 +0200 Subject: [PATCH 06/15] build in verbose mode --- .github/workflows/branchbuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/branchbuild.yml b/.github/workflows/branchbuild.yml index 129c448..0b3afa5 100644 --- a/.github/workflows/branchbuild.yml +++ b/.github/workflows/branchbuild.yml @@ -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: | From d30babb28bed855d13f4b78dfb1a49ad02bf46c7 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Thu, 22 Sep 2022 00:49:28 +0200 Subject: [PATCH 07/15] Update releasebuild.yml --- .github/workflows/releasebuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releasebuild.yml b/.github/workflows/releasebuild.yml index 99792dc..15e3944 100644 --- a/.github/workflows/releasebuild.yml +++ b/.github/workflows/releasebuild.yml @@ -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: | From ac9b1e31c210caba1cb034a7977b15fe4cba22dd Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Thu, 22 Sep 2022 00:53:59 +0200 Subject: [PATCH 08/15] Update CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fec574..1805862 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ 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() From 41d4890e94d72e9317847d63c6b2c534caaa3816 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 21 Sep 2022 22:27:09 -0400 Subject: [PATCH 09/15] WIP: Try SOABI --- src/jarowinkler/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jarowinkler/CMakeLists.txt b/src/jarowinkler/CMakeLists.txt index 62f43c4..6fd48e4 100644 --- a/src/jarowinkler/CMakeLists.txt +++ b/src/jarowinkler/CMakeLists.txt @@ -11,7 +11,7 @@ function(create_cython_target _name) endfunction(create_cython_target) create_cython_target(_initialize_cpp) -Python_add_library(_initialize_cpp MODULE ${_initialize_cpp}) +Python_add_library(_initialize_cpp MODULE WITH_SOABI ${_initialize_cpp}) 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) From 201f46955fa02137c47c48ca2a12b7e0d435568c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 21 Sep 2022 23:19:50 -0400 Subject: [PATCH 10/15] WIP: try manipulating the SOABI --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1805862..e8ebc05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,17 @@ project(jarowinkler LANGUAGES C CXX) if(CMAKE_VERSION VERSION_LESS 3.18) find_package(Python COMPONENTS Interpreter Development REQUIRED) else() + set(Python_ARTIFACTS_INTERACTIVE TRUE) find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) endif() +message(STATUS "Orignal SOABI: ${Python_SOABI}") +string(TOLOWER "${CMAKE_SYSTEM_NAME}" lower_system_name) +if(NOT Python_SOABI MATCHES "${lower_system_name}$") + set(Python_SOABI "${Python_SOABI}-${lower_system_name}") +endif() +message(STATUS "New SOABI: ${Python_SOABI}") + include(FetchContent) set(JW_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) From 665721b1f5808fe0b9acd7eb07a582d461023c7c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 21 Sep 2022 23:45:56 -0400 Subject: [PATCH 11/15] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8ebc05..b40dda4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ endif() message(STATUS "Orignal SOABI: ${Python_SOABI}") string(TOLOWER "${CMAKE_SYSTEM_NAME}" lower_system_name) -if(NOT Python_SOABI MATCHES "${lower_system_name}$") +if(NOT Python_SOABI MATCHES "${lower_system_name}") set(Python_SOABI "${Python_SOABI}-${lower_system_name}") endif() message(STATUS "New SOABI: ${Python_SOABI}") From 5f84240f40200b7ff9584e39cd6511ded1cf50cc Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Sep 2022 00:08:26 -0400 Subject: [PATCH 12/15] Update CMakeLists.txt --- CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b40dda4..5eb2a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,18 @@ else() find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) endif() -message(STATUS "Orignal SOABI: ${Python_SOABI}") -string(TOLOWER "${CMAKE_SYSTEM_NAME}" lower_system_name) -if(NOT Python_SOABI MATCHES "${lower_system_name}") - set(Python_SOABI "${Python_SOABI}-${lower_system_name}") +if("${Python_INTERPRETER_ID}" STREQUALS "PyPy") + execute_process( + COMMAND "${Python_EXECUTABLE}" -c + "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))" + OUTPUT_VARIABLE _multiarch + OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) + message(STATUS "PyPy SOABI: ${Python_SOABI}") + if(NOT Python_SOABI MATCHES "${_multiarch}$") + set(Python_SOABI "${Python_SOABI}-${_multiarch}") + message(STATUS "New SOABI: ${Python_SOABI}") + endif() endif() -message(STATUS "New SOABI: ${Python_SOABI}") include(FetchContent) From 42c2f9ad3418422dfe18aa7bccc6b788c260beed Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Sep 2022 00:18:47 -0400 Subject: [PATCH 13/15] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eb2a31..9b36c1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ else() find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) endif() -if("${Python_INTERPRETER_ID}" STREQUALS "PyPy") +if("${Python_INTERPRETER_ID}" STREQUAL "PyPy") execute_process( COMMAND "${Python_EXECUTABLE}" -c "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))" From 95cb6793a0a34958eb74c3e872803129d01a18cf Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Sep 2022 00:47:21 -0400 Subject: [PATCH 14/15] WIP: try manipulating the SOABI --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b36c1b..70ffbaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,12 +16,12 @@ endif() if("${Python_INTERPRETER_ID}" STREQUAL "PyPy") execute_process( COMMAND "${Python_EXECUTABLE}" -c - "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))" - OUTPUT_VARIABLE _multiarch + "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX').split('.')[1])" + OUTPUT_VARIABLE _platform_tag OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) message(STATUS "PyPy SOABI: ${Python_SOABI}") - if(NOT Python_SOABI MATCHES "${_multiarch}$") - set(Python_SOABI "${Python_SOABI}-${_multiarch}") + if(NOT Python_SOABI MATCHES "${_platform_tag}$") + set(Python_SOABI "${Python_SOABI}-${_platform_tag}") message(STATUS "New SOABI: ${Python_SOABI}") endif() endif() From da1296bfce7efb7d4af182b096e2034801630e5f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Sep 2022 00:57:01 -0400 Subject: [PATCH 15/15] Update CMakeLists.txt --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70ffbaf..6af2448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,16 +14,13 @@ else() 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 _platform_tag + OUTPUT_VARIABLE Python_SOABI OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) - message(STATUS "PyPy SOABI: ${Python_SOABI}") - if(NOT Python_SOABI MATCHES "${_platform_tag}$") - set(Python_SOABI "${Python_SOABI}-${_platform_tag}") - message(STATUS "New SOABI: ${Python_SOABI}") - endif() + message(STATUS "Corrected SOABI: ${Python_SOABI}") endif() include(FetchContent)