Skip to content

Commit f45db97

Browse files
rmdg88dolfim-ibm
andauthored
Rui/add windows ci (#21)
* add windows ci Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> * Update wheels.yml Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> * cleanup steps Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> * cleanup publish steps Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> * install poetry without 3rd party action Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> * trigger CI Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: rmdg88 <[email protected]> * update std lib and other fixes Signed-off-by: rmdg88 <[email protected]> --------- Signed-off-by: Rui Gomes <[email protected]> Signed-off-by: rmdg88 <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> Co-authored-by: Michele Dolfi <[email protected]>
1 parent 24bdedb commit f45db97

File tree

13 files changed

+195
-80
lines changed

13 files changed

+195
-80
lines changed

.github/workflows/wheels.yml

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
macos_version: "14"
4242
platform_id: "macosx_arm64"
4343

44+
- name: "windows-latest"
45+
platform: "windows"
46+
platform_id: "win_amd64"
47+
4448
steps:
4549
- name: Checkout
4650
uses: actions/checkout@v4
@@ -50,13 +54,20 @@ jobs:
5054
with:
5155
python-version: ${{ matrix.python-version }}
5256

53-
- name: Install poetry
54-
run: pipx install poetry==1.8.3 --python $(which python3)
55-
shell: bash
56-
57-
- name: Test poetry
57+
- name: Install Poetry
58+
run: python -m pip install poetry==1.8.3
59+
60+
- name: Set up custom PATH and set py version to cpXYZ [windows]
61+
if: ${{matrix.os.platform_id == 'win_amd64'}}
62+
shell: pwsh
5863
run: |
59-
poetry run python --version
64+
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
65+
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
66+
echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
67+
echo "C:\nasm" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
68+
$version = "${{ matrix.python-version }}"
69+
$cp_version = "cp$($version -replace '\.', '')"
70+
Add-Content -Path $env:GITHUB_ENV -Value "python_cp_version=$cp_version"
6071
6172
- name: Setup pypi for poetry [for releases only]
6273
if: ${{ startsWith(github.ref, 'refs/tags/') }}
@@ -65,6 +76,7 @@ jobs:
6576
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
6677
6778
- name: Convert python version to cpXYZ
79+
if: ${{matrix.os.platform_id != 'win_amd64'}}
6880
run: |
6981
version=${{ matrix.python-version }}
7082
cp_version="cp${version//.}"
@@ -147,20 +159,6 @@ jobs:
147159
mkdir ./dist
148160
cp wheelhouse/*.whl ./dist/
149161
150-
- name: publish wheels (dry run) [macos]
151-
if: matrix.os.platform == 'macos'
152-
run: |
153-
ls -l ./
154-
ls -l ./dist
155-
poetry publish --dry-run --no-interaction -vvv
156-
157-
- name: publish wheels (on publishing) [macos]
158-
if: ${{ matrix.os.platform == 'macos' && startsWith(github.ref, 'refs/tags/') }}
159-
run: |
160-
ls -l ./
161-
ls -l ./dist
162-
poetry publish --no-interaction -vvv
163-
164162
- name: Set up QEMU [linux]
165163
if: matrix.os.name == 'ubuntu-latest'
166164
uses: docker/setup-qemu-action@v3
@@ -191,17 +189,69 @@ jobs:
191189
mkdir ./dist
192190
cp wheelhouse/*.whl ./dist/
193191
194-
- name: publish wheels (dry run) [linux]
195-
if: matrix.os.platform == 'linux'
192+
- name: Set up MSYS2 [windows]
193+
if: ${{matrix.os.platform_id == 'win_amd64'}}
194+
uses: msys2/setup-msys2@v2
195+
with:
196+
update: true
197+
install: >
198+
mingw-w64-x86_64-toolchain
199+
mingw-w64-i686-toolchain
200+
201+
- name: Set up QPDF external-libs [windows]
202+
if: ${{matrix.os.platform_id == 'win_amd64'}}
203+
shell: pwsh
204+
run: |
205+
New-Item -Path 'C:\windows-libs' -ItemType Directory -Force
206+
Invoke-WebRequest -Uri 'https://github.com/qpdf/external-libs/releases/download/release-2024-06-07/qpdf-external-libs-bin.zip' -OutFile 'C:\windows-libs\qpdf-external-libs-bin.zip'
207+
Expand-Archive -Path 'C:\windows-libs\qpdf-external-libs-bin.zip' -DestinationPath 'C:\windows-libs' -Force
208+
Get-ChildItem -Path 'C:\windows-libs' -Recurse
209+
210+
- name: Set up NASM assembler [windows]
211+
if: ${{matrix.os.platform_id == 'win_amd64'}}
212+
shell: pwsh
213+
run: |
214+
New-Item -Path 'C:\nasm' -ItemType Directory -Force
215+
Invoke-WebRequest -Uri 'https://fossies.org/windows/misc/nasm-2.16.03-win64.zip/nasm-2.16.03/nasm.exe' -OutFile 'C:\nasm\nasm.exe'
216+
nasm -v
217+
218+
- name: Build wheels
219+
if: ${{matrix.os.platform_id == 'win_amd64'}}
220+
env:
221+
CIBW_PLATFORM: windows
222+
CIBW_BUILD_VERBOSITY: 3
223+
CIBW_ARCHS: AMD64
224+
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
225+
PKG_CONFIG_PATH: "C:/msys64/mingw64/lib/pkgconfig"
226+
PKG_CONFIG_EXECUTABLE: "C:/msys64/usr/bin/pkg-config.exe"
227+
CMAKE_PREFIX_PATH: "C:/msys64/mingw64;C:/windows-libs/external-libs"
228+
CMAKE_LIBRARY_PATH: "C:/msys64/mingw64/lib;C:/windows-libs/external-libs/lib-mingw64"
229+
CMAKE_INCLUDE_PATH: "C:/msys64/mingw64/include;C:/windows-libs/external-libs/include"
230+
CMAKE_GENERATOR: "MSYS Makefiles"
231+
BUILD_THREADS: 1
232+
ASM_NASM: "C:/nasm/nasm.exe"
233+
shell: pwsh
234+
run: |
235+
Remove-Item -Recurse -Force "C:\Strawberry\"
236+
$env:CMAKE_ARGS = "-DZLIB_LIBRARY=C:/windows-libs/external-libs/lib-mingw64/libz.a -DZLIB_INCLUDE_DIR=C:/windows-libs/external-libs/include -DJPEG_LIBRARY=C:/windows-libs/external-libs/lib-mingw64/libjpeg.a -DJPEG_INCLUDE_DIR=C:/windows-libs/external-libs/include"
237+
poetry install --no-interaction --no-root --only=build
238+
poetry run python -m cibuildwheel --output-dir .\wheelhouse
239+
Get-ChildItem -Path .\wheelhouse -Filter *.whl | Format-List
240+
Get-ChildItem -Path .\wheelhouse -Filter *.whl | ForEach-Object {
241+
$file = $_.FullName
242+
Write-Output "Inspecting $file"
243+
poetry run python -m zipfile --list "$file"
244+
}
245+
if (-not (Test-Path -Path .\dist)) {
246+
New-Item -Path .\dist -ItemType Directory
247+
}
248+
Copy-Item -Path .\wheelhouse\*.whl -Destination .\dist\
249+
250+
- name: publish wheels (dry run)
196251
run: |
197-
ls -l ./
198-
ls -l ./dist
199252
poetry publish --dry-run --no-interaction -vvv
200253
201-
- name: publish wheels (on publishing) [linux]
202-
if: ${{ matrix.os.platform == 'linux' && startsWith(github.ref, 'refs/tags/') }}
254+
- name: publish wheels (on publishing) [for releases only]
255+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
203256
run: |
204-
ls -l ./
205-
ls -l ./dist
206257
poetry publish --no-interaction -vvv
207-

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ set(CMAKE_CXX_STANDARD 20)
6969
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7070

7171
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -g3 -DROOT_PATH='\"${TOPLEVEL_PREFIX_PATH}\"' ${ENV_ARCHFLAGS}")
72-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -O3 -DROOT_PATH='\"${TOPLEVEL_PREFIX_PATH}\"' ${ENV_ARCHFLAGS}")
72+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -O3 -DROOT_PATH='\"${TOPLEVEL_PREFIX_PATH}\"' ${ENV_ARCHFLAGS}")
73+
74+
if (WIN32)
75+
set(TEST_PATH "\\\"${TOPLEVEL_PREFIX_PATH}\\\"")
76+
add_definitions(-DROOT_PATH="\\\"${TOPLEVEL_PREFIX_PATH}\\\"")
77+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -O3 ${ENV_ARCHFLAGS}")
78+
else()
79+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -O3 -DROOT_PATH='\"${TOPLEVEL_PREFIX_PATH}\"' ${ENV_ARCHFLAGS}")
80+
endif()
7381

7482
message(STATUS "cxx-compiler: " ${CMAKE_CXX_COMPILER})
7583
message(STATUS "cxx-flags : " ${CMAKE_CXX_FLAGS})
@@ -147,7 +155,7 @@ include(FetchContent)
147155
FetchContent_Declare(pybind11
148156
FETCHCONTENT_BASE_DIR extlib_pybind11
149157
GIT_REPOSITORY https://github.com/pybind/pybind11.git
150-
GIT_TAG v2.10.0
158+
GIT_TAG v2.13.5
151159
GIT_SHALLOW TRUE
152160
)
153161
FetchContent_MakeAvailable(pybind11)
@@ -176,4 +184,3 @@ install(TARGETS docling_parse DESTINATION "${TOPLEVEL_PREFIX_PATH}/docling_parse
176184

177185
# do a bunch of result based tests
178186
# do_test(Tutorial 4 "4 is 2")
179-

cmake/extlib_pybind11.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(ExternalProject)
55
include(CMakeParseArguments)
66

77
set(PYBIND11_URL https://github.com/pybind/pybind11.git)
8-
set(PYBIND11_TAG v2.10.0)
8+
set(PYBIND11_TAG v2.13.5)
99

1010
ExternalProject_Add(extlib_pybind11
1111
PREFIX extlib_pybind11
@@ -25,4 +25,4 @@ ExternalProject_Add(extlib_pybind11
2525

2626
add_library(pybind11 INTERFACE)
2727
add_custom_target(install_extlib_pybind11 DEPENDS extlib_pybind11)
28-
add_dependencies(pybind11 install_extlib_pybind11)
28+
add_dependencies(pybind11 install_extlib_pybind11)

cmake/os_opts.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ message(STATUS "entering in 'os_opts.cmake'")
44
if(WIN32)
55
message(STATUS "compiling on windows")
66

7+
set(LIB_LINK qpdf jpeg utf8 z)
8+
79
elseif(APPLE)
810
message(STATUS "compiling on mac-osx")
911

@@ -27,5 +29,3 @@ elseif(UNIX)
2729
list(APPEND LIB_LINK dl m pthread rt resolv)
2830

2931
endif()
30-
31-

src/include_libs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
#include <assert.h>
77
#include <filesystem>
88
#include <iostream>
9+
#include <string>

src/proj_folders/pdf_interface/parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ namespace pdf_lib
296296

297297
// FIXME
298298
//std::string font_data_dir = PDF_DATA_DIR;
299-
std::string font_data_dir = resource_utils::get_resources_dir(true);
299+
//std::string font_data_dir = resource_utils::get_resources_dir(true);
300+
std::string font_data_dir = resource_utils::get_resources_dir(true).string();
300301

301302
std::vector<std::string> font_data_key = {"font-data", "path"};
302303
if (input.has(font_data_key))

src/proj_folders/pdf_library/core/tools/writer.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ namespace pdf_lib
5252
std::pair<scalar_type, scalar_type> page_r0,
5353
std::pair<scalar_type, scalar_type> page_dim);
5454

55-
template<typename scalar_type, long unsigned int N>
55+
// template<typename scalar_type, long unsigned int N>
56+
// std::vector<scalar_type> to_vector(std::array<scalar_type, N> arr);
57+
template<typename scalar_type, std::size_t N>
5658
std::vector<scalar_type> to_vector(std::array<scalar_type, N> arr);
57-
59+
5860
template<typename scalar_type>
5961
std::vector<scalar_type> get_bvec(std::array<scalar_type, 4> rhs);
6062

@@ -296,14 +298,24 @@ namespace pdf_lib
296298
}
297299
}
298300

299-
template<typename scalar_type, long unsigned int N>
301+
// template<typename scalar_type, long unsigned int N>
302+
// std::vector<scalar_type> writer::to_vector(std::array<scalar_type, N> arr)
303+
// {
304+
// std::vector<scalar_type> result(N, 0);
305+
306+
// for(int l=0; l<N; l++)
307+
// result[l] = arr[l];
308+
309+
// return result;
310+
// }
311+
template<typename scalar_type, std::size_t N>
300312
std::vector<scalar_type> writer::to_vector(std::array<scalar_type, N> arr)
301313
{
302-
std::vector<scalar_type> result(N, 0);
314+
std::vector<scalar_type> result(arr.size(), 0);
315+
316+
for(std::size_t l = 0; l < arr.size(); ++l)
317+
result[l] = arr[l];
303318

304-
for(int l=0; l<N; l++)
305-
result[l] = arr[l];
306-
307319
return result;
308320
}
309321

@@ -733,5 +745,4 @@ namespace pdf_lib
733745

734746
}
735747

736-
#endif
737-
748+
#endif

src/proj_folders/pdf_library/qpdf/parser/cid_cmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ namespace pdf_lib
4040

4141
// FIXME
4242
//directory = PDF_DATA_DIR;
43-
directory = resource_utils::get_resources_dir(true);
43+
//directory = resource_utils::get_resources_dir(true);
44+
directory = resource_utils::get_resources_dir(true).string();
4445

4546
directory += directory.back()!='/'? "/":"";
4647

src/proj_folders/pdf_library/qpdf/parser/cid_to_utf8.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ namespace pdf_lib
4040
{
4141
// FIXME
4242
//directory = PDF_DATA_DIR;
43-
directory = resource_utils::get_resources_dir(true);
43+
//directory = resource_utils::get_resources_dir(true);
44+
directory = resource_utils::get_resources_dir(true).string();
4445

4546
directory += directory.back()!='/'? "/":"";
4647

src/pybind/docling_parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ namespace docling
7777
docling_resources(),
7878
interface()
7979
{
80-
std::string font_data_dir = resource_utils::get_resources_dir(true);
80+
// std::string font_data_dir = resource_utils::get_resources_dir(true);
81+
std::string font_data_dir = resource_utils::get_resources_dir(true).string();
8182

8283
pdf_lib::core::object<pdf_lib::core::FONT>::initialize(font_data_dir);
8384
}

0 commit comments

Comments
 (0)