Skip to content

Commit 8a3d5cd

Browse files
sebastianMindeeianardee
authored andcommitted
✨ add full support for image processing through bernard l'édit
1 parent 3bfc865 commit 8a3d5cd

42 files changed

Lines changed: 530 additions & 702 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/dependabot.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ updates:
1717
- "requests"
1818
optional-dependencies:
1919
patterns:
20-
- "pypdfium2"
21-
- "Pillow"
20+
- "bernard_ledit"
2221
test-dependencies:
2322
patterns:
2423
- "pytest"
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build bernard-ledit Wheel
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-wheel:
12+
name: Build bernard-ledit wheel
13+
timeout-minutes: 30
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- "ubuntu-22.04"
19+
- "windows-2022"
20+
- "macos-latest"
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- uses: actions/checkout@v6
24+
with:
25+
submodules: recursive
26+
27+
- name: Set up Python 3.10
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: "3.10"
31+
32+
- name: Resolve bernard-ledit submodule commit
33+
id: bernard
34+
shell: bash
35+
run: echo "sha=$(git -C bernard-ledit rev-parse HEAD)" >> "$GITHUB_OUTPUT"
36+
37+
# Skip the whole Rust/maturin build when the submodule pointer is unchanged.
38+
- name: Restore cached bernard-ledit build
39+
id: cache
40+
uses: actions/cache@v5
41+
with:
42+
path: ./.github/artifacts/bernard-ledit
43+
key: bernard-ledit-${{ runner.os }}-${{ steps.bernard.outputs.sha }}
44+
45+
- name: Cache downloaded PDFium binary
46+
if: steps.cache.outputs.cache-hit != 'true'
47+
uses: actions/cache@v5
48+
with:
49+
path: bernard-ledit/core/.pdfium_cache
50+
key: pdfium-${{ runner.os }}-${{ hashFiles('bernard-ledit/core/build.rs') }}
51+
restore-keys: |
52+
pdfium-${{ runner.os }}-
53+
54+
- name: Cache Rust build
55+
if: steps.cache.outputs.cache-hit != 'true'
56+
uses: Swatinem/rust-cache@v2
57+
with:
58+
workspaces: bernard-ledit
59+
key: ${{ steps.bernard.outputs.sha }}
60+
61+
- name: Build bernard-ledit wheel
62+
if: steps.cache.outputs.cache-hit != 'true'
63+
shell: bash
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip wheel --no-deps --wheel-dir ./.github/artifacts/bernard-ledit bernard-ledit/bindings/python/
67+
68+
# The wheel does not embed PDFium; ship the library so consumers can set PDFIUM_PATH.
69+
- name: Collect bundled PDFium library
70+
if: steps.cache.outputs.cache-hit != 'true'
71+
shell: bash
72+
run: |
73+
lib=$(find bernard-ledit/core/.pdfium_cache \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print | head -n 1)
74+
if [ -z "$lib" ]; then
75+
echo "::error::PDFium library not found under bernard-ledit/core/.pdfium_cache after build"
76+
exit 1
77+
fi
78+
cp "$lib" ./.github/artifacts/bernard-ledit/
79+
echo "Bundled PDFium library: $(basename "$lib")"
80+
81+
- name: Upload bernard-ledit build
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: bernard-ledit-wheel-${{ runner.os }}
85+
path: |
86+
./.github/artifacts/bernard-ledit/*.whl
87+
./.github/artifacts/bernard-ledit/libpdfium.*
88+
./.github/artifacts/bernard-ledit/pdfium.dll
89+
if-no-files-found: error

‎.github/workflows/_smoke-test.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,25 @@ jobs:
4242
restore-keys: |
4343
${{ runner.os }}-samples-
4444
45+
- name: Download prebuilt bernard-ledit wheel
46+
uses: actions/download-artifact@v5
47+
continue-on-error: true
48+
with:
49+
name: bernard-ledit-wheel-${{ runner.os }}
50+
path: ./.github/artifacts/bernard-ledit
51+
52+
- name: Locate bundled PDFium
53+
shell: bash
54+
run: |
55+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
56+
if [ -n "$lib" ]; then
57+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
58+
fi
59+
4560
- name: Install dependencies
4661
run: |
4762
python -m pip install pip
63+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
4864
pip install -e '.'
4965
5066
- name: Tests v2 sample code

‎.github/workflows/_static-analysis.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v7
1818
with:
19+
submodules: recursive
1920
fetch-depth: 0
2021

2122
- name: Run Betterleaks
@@ -51,15 +52,35 @@ jobs:
5152
restore-keys: |
5253
${{ runner.os }}-lint-
5354
55+
- name: Download prebuilt bernard-ledit wheel
56+
uses: actions/download-artifact@v5
57+
continue-on-error: true
58+
with:
59+
name: bernard-ledit-wheel-${{ runner.os }}
60+
path: ./.github/artifacts/bernard-ledit
61+
62+
- name: Locate bundled PDFium
63+
shell: bash
64+
run: |
65+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
66+
if [ -n "$lib" ]; then
67+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
68+
fi
69+
5470
- name: Install dependencies
5571
run: |
5672
python -m pip install pip
73+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
5774
pip install -e '.[lint]'
5875
5976
- name: License check
6077
run: |
6178
pylic check --allow-extra-safe-licenses
6279
80+
- name: Audit dependencies
81+
run: |
82+
pip-audit --local --skip-editable
83+
6384
- name: Cache pre-commit
6485
uses: actions/cache@v6
6586
with:

‎.github/workflows/_test-cli.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,25 @@ jobs:
4848
restore-keys: |
4949
${{ runner.os }}-cli-
5050
51+
- name: Download prebuilt bernard-ledit wheel
52+
uses: actions/download-artifact@v5
53+
continue-on-error: true
54+
with:
55+
name: bernard-ledit-wheel-${{ runner.os }}
56+
path: ./.github/artifacts/bernard-ledit
57+
58+
- name: Locate bundled PDFium
59+
shell: bash
60+
run: |
61+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
62+
if [ -n "$lib" ]; then
63+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
64+
fi
65+
5166
- name: Install dependencies
5267
run: |
5368
python -m pip install pip
69+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
5470
pip install -e '.'
5571
5672
- name: Test V1 CLI

‎.github/workflows/_test-integrations.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,25 @@ jobs:
5252
restore-keys: |
5353
${{ runner.os }}-test-
5454
55+
- name: Download prebuilt bernard-ledit wheel
56+
uses: actions/download-artifact@v5
57+
continue-on-error: true
58+
with:
59+
name: bernard-ledit-wheel-${{ runner.os }}
60+
path: ./.github/artifacts/bernard-ledit
61+
62+
- name: Locate bundled PDFium
63+
shell: bash
64+
run: |
65+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
66+
if [ -n "$lib" ]; then
67+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
68+
fi
69+
5570
- name: Install dependencies
5671
run: |
5772
python -m pip install pip
73+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
5874
pip install -e '.[test]'
5975
- name: Run Integration Testing
6076
run: |
@@ -107,4 +123,4 @@ jobs:
107123
shell: bash
108124
- name: Run Integration Testing
109125
run: |
110-
pytest -m "integration and not pypdfium2 and not pillow"
126+
pytest -m "integration and not bernard_ledit"

‎.github/workflows/_test-regressions.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,25 @@ jobs:
3838
restore-keys: |
3939
${{ runner.os }}-test-
4040
41+
- name: Download prebuilt bernard-ledit wheel
42+
uses: actions/download-artifact@v5
43+
continue-on-error: true
44+
with:
45+
name: bernard-ledit-wheel-${{ runner.os }}
46+
path: ./.github/artifacts/bernard-ledit
47+
48+
- name: Locate bundled PDFium
49+
shell: bash
50+
run: |
51+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
52+
if [ -n "$lib" ]; then
53+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
54+
fi
55+
4156
- name: Install dependencies
4257
run: |
4358
python -m pip install pip
59+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
4460
pip install -e '.[test]'
4561
- name: Run Regression Testing
4662
env:

‎.github/workflows/_test-units.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
os:
1616
- "ubuntu-22.04"
1717
- "windows-2022"
18+
- "macos-latest"
1819
python-version:
1920
- "3.10"
2021
- "3.11"
@@ -40,9 +41,25 @@ jobs:
4041
restore-keys: |
4142
${{ runner.os }}-test-
4243
44+
- name: Download prebuilt bernard-ledit wheel
45+
uses: actions/download-artifact@v5
46+
continue-on-error: true
47+
with:
48+
name: bernard-ledit-wheel-${{ runner.os }}
49+
path: ./.github/artifacts/bernard-ledit
50+
51+
- name: Locate bundled PDFium
52+
shell: bash
53+
run: |
54+
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
55+
if [ -n "$lib" ]; then
56+
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
57+
fi
58+
4359
- name: Install dependencies
4460
run: |
4561
python -m pip install pip
62+
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
4663
pip install -e '.[test]'
4764
4865
- name: Unit testing with pytest
@@ -57,6 +74,7 @@ jobs:
5774
os:
5875
- "ubuntu-22.04"
5976
- "windows-2022"
77+
- "macos-latest"
6078
python-version:
6179
- "3.10"
6280
- "3.14"
@@ -90,4 +108,3 @@ jobs:
90108
- name: Unit testing with pytest
91109
run: |
92110
pytest
93-

‎.github/workflows/cron.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ permissions:
1010
actions: read
1111

1212
jobs:
13+
build-bernard-ledit:
14+
uses: mindee/mindee-api-python/.github/workflows/_build-bernard-ledit.yml@main
1315
test-regressions:
1416
uses: mindee/mindee-api-python/.github/workflows/_test-regressions.yml@main
17+
needs: build-bernard-ledit
1518
secrets: inherit
1619
test-code-samples:
1720
uses: mindee/mindee-api-python/.github/workflows/_smoke-test.yml@main
21+
needs: build-bernard-ledit
1822
secrets: inherit
1923
test-cli:
2024
uses: mindee/mindee-api-python/.github/workflows/_test-cli.yml@main
25+
needs: build-bernard-ledit
2126
secrets: inherit

‎.github/workflows/pull-request.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ permissions:
1010
jobs:
1111
workflow-lint:
1212
uses: ./.github/workflows/_workflow_lint.yml
13+
build-bernard-ledit:
14+
uses: ./.github/workflows/_build-bernard-ledit.yml
1315
static-analysis:
1416
uses: ./.github/workflows/_static-analysis.yml
15-
needs: workflow-lint
17+
needs:
18+
- workflow-lint
19+
- build-bernard-ledit
1620
test-units:
1721
uses: ./.github/workflows/_test-units.yml
18-
needs: static-analysis
22+
needs: build-bernard-ledit
1923
secrets: inherit
2024
test-regressions:
2125
uses: ./.github/workflows/_test-regressions.yml

0 commit comments

Comments
 (0)