doc2struct 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. doc2struct-0.1.0/.github/workflows/release.yml +291 -0
  2. doc2struct-0.1.0/.gitignore +41 -0
  3. doc2struct-0.1.0/CMakeLists.txt +26 -0
  4. doc2struct-0.1.0/LICENSE +21 -0
  5. doc2struct-0.1.0/PKG-INFO +509 -0
  6. doc2struct-0.1.0/build_scripts/build_pdfium.py +211 -0
  7. doc2struct-0.1.0/build_scripts/generate_presets.py +41 -0
  8. doc2struct-0.1.0/build_scripts/package_native.py +84 -0
  9. doc2struct-0.1.0/build_scripts/repair_wheel.py +60 -0
  10. doc2struct-0.1.0/build_scripts/smoke_release.py +127 -0
  11. doc2struct-0.1.0/build_scripts/validate_pdfium.py +34 -0
  12. doc2struct-0.1.0/c/CMakeLists.txt +163 -0
  13. doc2struct-0.1.0/c/bench/test_many.c +252 -0
  14. doc2struct-0.1.0/c/bench/text_many.c +66 -0
  15. doc2struct-0.1.0/c/doc2structConfig.cmake.in +9 -0
  16. doc2struct-0.1.0/c/include/doc2struct/doc2struct.h +181 -0
  17. doc2struct-0.1.0/c/src/api.c +125 -0
  18. doc2struct-0.1.0/c/src/cli.c +93 -0
  19. doc2struct-0.1.0/c/src/config.c +334 -0
  20. doc2struct-0.1.0/c/src/config_json.c +219 -0
  21. doc2struct-0.1.0/c/src/config_json.h +16 -0
  22. doc2struct-0.1.0/c/src/doc2struct.h +231 -0
  23. doc2struct-0.1.0/c/src/flow.c +416 -0
  24. doc2struct-0.1.0/c/src/json.c +138 -0
  25. doc2struct-0.1.0/c/src/lists.c +327 -0
  26. doc2struct-0.1.0/c/src/memory.c +282 -0
  27. doc2struct-0.1.0/c/src/normalizer.c +518 -0
  28. doc2struct-0.1.0/c/src/parser.c +27 -0
  29. doc2struct-0.1.0/c/src/pdf.c +347 -0
  30. doc2struct-0.1.0/c/src/pdf.h +12 -0
  31. doc2struct-0.1.0/c/src/pdf_layout.c +191 -0
  32. doc2struct-0.1.0/c/src/preset_data.h +13170 -0
  33. doc2struct-0.1.0/c/src/rules.c +221 -0
  34. doc2struct-0.1.0/c/src/scan.h +220 -0
  35. doc2struct-0.1.0/c/src/standardized_text.c +1180 -0
  36. doc2struct-0.1.0/c/src/tables.c +623 -0
  37. doc2struct-0.1.0/c/src/tags.h +235 -0
  38. doc2struct-0.1.0/c/src/text.c +450 -0
  39. doc2struct-0.1.0/c/src/text_layout.c +1087 -0
  40. doc2struct-0.1.0/c/src/tokenizer.c +572 -0
  41. doc2struct-0.1.0/c/src/unicode_data.h +28968 -0
  42. doc2struct-0.1.0/c/vendor/pcre2/AUTHORS.md +221 -0
  43. doc2struct-0.1.0/c/vendor/pcre2/LICENCE.md +104 -0
  44. doc2struct-0.1.0/c/vendor/pcre2/SOURCE.txt +9 -0
  45. doc2struct-0.1.0/c/vendor/pcre2/config.h +497 -0
  46. doc2struct-0.1.0/c/vendor/pcre2/config.h.generic +497 -0
  47. doc2struct-0.1.0/c/vendor/pcre2/pcre2.h +1080 -0
  48. doc2struct-0.1.0/c/vendor/pcre2/pcre2.h.generic +1080 -0
  49. doc2struct-0.1.0/c/vendor/pcre2/pcre2_auto_possess.c +1416 -0
  50. doc2struct-0.1.0/c/vendor/pcre2/pcre2_chartables.c +192 -0
  51. doc2struct-0.1.0/c/vendor/pcre2/pcre2_chkdint.c +94 -0
  52. doc2struct-0.1.0/c/vendor/pcre2/pcre2_compile.c +11412 -0
  53. doc2struct-0.1.0/c/vendor/pcre2/pcre2_compile.h +356 -0
  54. doc2struct-0.1.0/c/vendor/pcre2/pcre2_compile_cgroup.c +632 -0
  55. doc2struct-0.1.0/c/vendor/pcre2/pcre2_compile_class.c +2779 -0
  56. doc2struct-0.1.0/c/vendor/pcre2/pcre2_config.c +250 -0
  57. doc2struct-0.1.0/c/vendor/pcre2/pcre2_context.c +557 -0
  58. doc2struct-0.1.0/c/vendor/pcre2/pcre2_convert.c +1263 -0
  59. doc2struct-0.1.0/c/vendor/pcre2/pcre2_dfa_match.c +4164 -0
  60. doc2struct-0.1.0/c/vendor/pcre2/pcre2_error.c +386 -0
  61. doc2struct-0.1.0/c/vendor/pcre2/pcre2_extuni.c +159 -0
  62. doc2struct-0.1.0/c/vendor/pcre2/pcre2_find_bracket.c +217 -0
  63. doc2struct-0.1.0/c/vendor/pcre2/pcre2_internal.h +2360 -0
  64. doc2struct-0.1.0/c/vendor/pcre2/pcre2_intmodedep.h +1116 -0
  65. doc2struct-0.1.0/c/vendor/pcre2/pcre2_jit_char_inc.h +2280 -0
  66. doc2struct-0.1.0/c/vendor/pcre2/pcre2_jit_compile.c +14442 -0
  67. doc2struct-0.1.0/c/vendor/pcre2/pcre2_jit_match_inc.h +213 -0
  68. doc2struct-0.1.0/c/vendor/pcre2/pcre2_jit_misc_inc.h +260 -0
  69. doc2struct-0.1.0/c/vendor/pcre2/pcre2_jit_simd_inc.h +2506 -0
  70. doc2struct-0.1.0/c/vendor/pcre2/pcre2_maketables.c +177 -0
  71. doc2struct-0.1.0/c/vendor/pcre2/pcre2_match.c +8231 -0
  72. doc2struct-0.1.0/c/vendor/pcre2/pcre2_match_data.c +184 -0
  73. doc2struct-0.1.0/c/vendor/pcre2/pcre2_match_next.c +171 -0
  74. doc2struct-0.1.0/c/vendor/pcre2/pcre2_newline.c +239 -0
  75. doc2struct-0.1.0/c/vendor/pcre2/pcre2_ord2utf.c +118 -0
  76. doc2struct-0.1.0/c/vendor/pcre2/pcre2_pattern_info.c +430 -0
  77. doc2struct-0.1.0/c/vendor/pcre2/pcre2_printint_inc.h +1098 -0
  78. doc2struct-0.1.0/c/vendor/pcre2/pcre2_script_run.c +343 -0
  79. doc2struct-0.1.0/c/vendor/pcre2/pcre2_serialize.c +295 -0
  80. doc2struct-0.1.0/c/vendor/pcre2/pcre2_string_utils.c +199 -0
  81. doc2struct-0.1.0/c/vendor/pcre2/pcre2_study.c +2086 -0
  82. doc2struct-0.1.0/c/vendor/pcre2/pcre2_substitute.c +1795 -0
  83. doc2struct-0.1.0/c/vendor/pcre2/pcre2_substring.c +554 -0
  84. doc2struct-0.1.0/c/vendor/pcre2/pcre2_tables.c +310 -0
  85. doc2struct-0.1.0/c/vendor/pcre2/pcre2_ucd.c +5823 -0
  86. doc2struct-0.1.0/c/vendor/pcre2/pcre2_ucp.h +413 -0
  87. doc2struct-0.1.0/c/vendor/pcre2/pcre2_ucptables_inc.h +1621 -0
  88. doc2struct-0.1.0/c/vendor/pcre2/pcre2_util.h +179 -0
  89. doc2struct-0.1.0/c/vendor/pcre2/pcre2_valid_utf.c +397 -0
  90. doc2struct-0.1.0/c/vendor/pcre2/pcre2_xclass.c +547 -0
  91. doc2struct-0.1.0/c/vendor/pdfium/LICENSE +230 -0
  92. doc2struct-0.1.0/c/vendor/pdfium/bridge.cpp +209 -0
  93. doc2struct-0.1.0/c/vendor/pdfium/bridge.h +29 -0
  94. doc2struct-0.1.0/c/vendor/pdfium/fpdf_text.h +685 -0
  95. doc2struct-0.1.0/c/vendor/pdfium/fpdfview.h +1505 -0
  96. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_arm64/doc2struct_pdfium.so +0 -0
  97. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_arm64/licenses/pdfium.txt +230 -0
  98. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_arm64/licenses/third_party.txt +3874 -0
  99. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_arm64/version.json +12 -0
  100. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_x86_64/doc2struct_pdfium.so +0 -0
  101. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_x86_64/licenses/pdfium.txt +230 -0
  102. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_x86_64/licenses/third_party.txt +3874 -0
  103. doc2struct-0.1.0/c/vendor/pdfium/runtime/linux_x86_64/version.json +12 -0
  104. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_arm64/doc2struct_pdfium.dylib +0 -0
  105. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_arm64/licenses/pdfium.txt +230 -0
  106. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_arm64/licenses/third_party.txt +3874 -0
  107. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_arm64/version.json +12 -0
  108. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_x86_64/doc2struct_pdfium.dylib +0 -0
  109. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_x86_64/licenses/pdfium.txt +230 -0
  110. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_x86_64/licenses/third_party.txt +3874 -0
  111. doc2struct-0.1.0/c/vendor/pdfium/runtime/macos_x86_64/version.json +12 -0
  112. doc2struct-0.1.0/c/vendor/pdfium/runtime/win_amd64/doc2struct_pdfium.dll +0 -0
  113. doc2struct-0.1.0/c/vendor/pdfium/runtime/win_amd64/licenses/pdfium.txt +230 -0
  114. doc2struct-0.1.0/c/vendor/pdfium/runtime/win_amd64/licenses/third_party.txt +3874 -0
  115. doc2struct-0.1.0/c/vendor/pdfium/runtime/win_amd64/version.json +12 -0
  116. doc2struct-0.1.0/presets/defaults.json +74 -0
  117. doc2struct-0.1.0/presets/sec_filings.json +10197 -0
  118. doc2struct-0.1.0/pyproject.toml +57 -0
  119. doc2struct-0.1.0/python/native/module.c +1194 -0
  120. doc2struct-0.1.0/python/src/doc2struct/__init__.py +16 -0
  121. doc2struct-0.1.0/python/src/doc2struct/_engine.py +46 -0
  122. doc2struct-0.1.0/python/src/doc2struct/convert_html_to_instructions.py +12 -0
  123. doc2struct-0.1.0/python/src/doc2struct/convert_instructions_to_standardized_text.py +36 -0
  124. doc2struct-0.1.0/python/src/doc2struct/convert_partialsgml_to_instructions.py +20 -0
  125. doc2struct-0.1.0/python/src/doc2struct/convert_pdf_to_instructions.py +10 -0
  126. doc2struct-0.1.0/python/src/doc2struct/convert_text_to_instructions.py +15 -0
  127. doc2struct-0.1.0/python/src/doc2struct/html_token_normalizer.py +47 -0
  128. doc2struct-0.1.0/python/src/doc2struct/html_tokenizer.py +9 -0
  129. doc2struct-0.1.0/python/src/doc2struct/parser.py +95 -0
  130. doc2struct-0.1.0/python/src/doc2struct/rules/__init__.py +105 -0
  131. doc2struct-0.1.0/python/src/doc2struct/rules/defaults.py +36 -0
  132. doc2struct-0.1.0/python/src/doc2struct/rules/types.py +219 -0
  133. doc2struct-0.1.0/python/src/doc2struct/visualizer.py +250 -0
  134. doc2struct-0.1.0/readme.md +490 -0
@@ -0,0 +1,291 @@
1
+ name: Build and release
2
+
3
+ # Manual runs build downloadable artifacts without publishing anything.
4
+ # A version tag publishes only after every wheel and native SDK has passed.
5
+ on:
6
+ push:
7
+ tags: ["v*"]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: release-${{ github.ref }}
15
+ cancel-in-progress: false
16
+
17
+ jobs:
18
+ version:
19
+ runs-on: ubuntu-24.04
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.14"
25
+ - name: Check tag against the public C version
26
+ shell: python
27
+ run: |
28
+ import os, pathlib, re
29
+ header = pathlib.Path('c/include/doc2struct/doc2struct.h').read_text()
30
+ version = re.search(r'#define DOC2STRUCT_VERSION "([^"]+)"', header).group(1)
31
+ if os.environ['GITHUB_REF'].startswith('refs/tags/'):
32
+ assert os.environ['GITHUB_REF_NAME'] == 'v' + version, 'Tag must match DOC2STRUCT_VERSION'
33
+ print('Building doc2struct ' + version)
34
+
35
+ pdfium:
36
+ needs: version
37
+ timeout-minutes: 120
38
+ strategy:
39
+ fail-fast: false
40
+ matrix:
41
+ include:
42
+ - runner: ubuntu-24.04
43
+ runtime: linux_x86_64
44
+ args: --target-cpu x64
45
+ - runner: ubuntu-24.04
46
+ runtime: linux_arm64
47
+ args: --target-cpu arm64
48
+ - runner: windows-2022
49
+ runtime: win_amd64
50
+ args: ""
51
+ - runner: macos-14
52
+ runtime: macos_arm64
53
+ args: ""
54
+ - runner: macos-15-intel
55
+ runtime: macos_x86_64
56
+ args: ""
57
+ runs-on: ${{ matrix.runner }}
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ - uses: actions/setup-python@v5
61
+ with:
62
+ python-version: "3.14"
63
+ - name: Install Linux build prerequisites
64
+ if: runner.os == 'Linux'
65
+ run: sudo apt-get update && sudo apt-get install -y pkg-config libglib2.0-dev
66
+ - uses: actions/cache@v4
67
+ id: runtime-cache
68
+ with:
69
+ path: c/vendor/pdfium/runtime/${{ matrix.runtime }}
70
+ key: pdfium-${{ matrix.runner }}-${{ matrix.runtime }}-${{ hashFiles('build_scripts/build_pdfium.py', 'c/vendor/pdfium/bridge.cpp', 'c/vendor/pdfium/bridge.h') }}
71
+ - name: Build pinned private PDFium once per platform
72
+ if: steps.runtime-cache.outputs.cache-hit != 'true'
73
+ run: python build_scripts/build_pdfium.py --fetch --jobs 4 ${{ matrix.args }}
74
+ - name: Validate engine bundle
75
+ shell: bash
76
+ run: |
77
+ extra=""
78
+ if [ "${{ matrix.runtime }}" = linux_arm64 ]; then extra="--no-load"; fi
79
+ python build_scripts/validate_pdfium.py c/vendor/pdfium/runtime/${{ matrix.runtime }}/doc2struct_pdfium.* $extra
80
+ - uses: actions/upload-artifact@v4
81
+ with:
82
+ name: pdfium-${{ matrix.runtime }}
83
+ path: c/vendor/pdfium/runtime/${{ matrix.runtime }}/
84
+ if-no-files-found: error
85
+
86
+ wheels:
87
+ needs: pdfium
88
+ timeout-minutes: 90
89
+ strategy:
90
+ fail-fast: false
91
+ matrix:
92
+ include:
93
+ - runner: ubuntu-24.04
94
+ runtime: linux_x86_64
95
+ arch: x86_64
96
+ - runner: ubuntu-24.04-arm
97
+ runtime: linux_arm64
98
+ arch: aarch64
99
+ - runner: windows-2022
100
+ runtime: win_amd64
101
+ arch: AMD64
102
+ - runner: macos-14
103
+ runtime: macos_arm64
104
+ arch: arm64
105
+ - runner: macos-15-intel
106
+ runtime: macos_x86_64
107
+ arch: x86_64
108
+ runs-on: ${{ matrix.runner }}
109
+ steps:
110
+ - uses: actions/checkout@v4
111
+ - uses: actions/download-artifact@v4
112
+ with:
113
+ name: pdfium-${{ matrix.runtime }}
114
+ path: c/vendor/pdfium/runtime/${{ matrix.runtime }}
115
+ - uses: pypa/cibuildwheel@v4.3.5
116
+ env:
117
+ CIBW_ARCHS: ${{ matrix.arch }}
118
+ - uses: actions/upload-artifact@v4
119
+ with:
120
+ name: wheels-${{ matrix.runtime }}
121
+ path: wheelhouse/*.whl
122
+ if-no-files-found: error
123
+
124
+ native:
125
+ needs: pdfium
126
+ timeout-minutes: 30
127
+ strategy:
128
+ fail-fast: false
129
+ matrix:
130
+ include:
131
+ - runner: ubuntu-24.04
132
+ runtime: linux_x86_64
133
+ platform: linux_x86_64
134
+ container: quay.io/pypa/manylinux_2_34_x86_64
135
+ - runner: ubuntu-24.04-arm
136
+ runtime: linux_arm64
137
+ platform: linux_aarch64
138
+ container: quay.io/pypa/manylinux_2_34_aarch64
139
+ - runner: windows-2022
140
+ runtime: win_amd64
141
+ platform: win_amd64
142
+ - runner: macos-14
143
+ runtime: macos_arm64
144
+ platform: macos_arm64
145
+ - runner: macos-15-intel
146
+ runtime: macos_x86_64
147
+ platform: macos_x86_64
148
+ runs-on: ${{ matrix.runner }}
149
+ steps:
150
+ - uses: actions/checkout@v4
151
+ - uses: actions/setup-python@v5
152
+ with:
153
+ python-version: "3.14"
154
+ - uses: actions/download-artifact@v4
155
+ with:
156
+ name: pdfium-${{ matrix.runtime }}
157
+ path: c/vendor/pdfium/runtime/${{ matrix.runtime }}
158
+ - name: Package Linux SDK and CLI on their target architecture
159
+ if: runner.os == 'Linux'
160
+ run: >-
161
+ docker run --rm -v "$PWD:/project" -w /project ${{ matrix.container }}
162
+ /opt/python/cp314-cp314/bin/python build_scripts/package_native.py
163
+ --platform ${{ matrix.platform }}
164
+ - name: Package Windows or macOS SDK and CLI
165
+ if: runner.os != 'Linux'
166
+ run: python build_scripts/package_native.py --platform ${{ matrix.platform }}
167
+ env:
168
+ MACOSX_DEPLOYMENT_TARGET: "14.0"
169
+ - uses: actions/upload-artifact@v4
170
+ with:
171
+ name: native-${{ matrix.platform }}
172
+ path: dist/*
173
+ if-no-files-found: error
174
+
175
+ sdist:
176
+ needs: pdfium
177
+ runs-on: ubuntu-24.04
178
+ steps:
179
+ - uses: actions/checkout@v4
180
+ - uses: actions/setup-python@v5
181
+ with:
182
+ python-version: "3.14"
183
+ - uses: actions/download-artifact@v4
184
+ with:
185
+ pattern: pdfium-*
186
+ path: build/runtimes
187
+ - name: Include all platform engines in the source distribution
188
+ shell: python
189
+ run: |
190
+ import pathlib, shutil
191
+ for bundle in pathlib.Path('build/runtimes').glob('pdfium-*'):
192
+ key = bundle.name.removeprefix('pdfium-')
193
+ shutil.copytree(bundle, pathlib.Path('c/vendor/pdfium/runtime') / key, dirs_exist_ok=True)
194
+ - run: python -m pip install build
195
+ - run: python -m build --sdist
196
+ - name: Build and exercise a wheel from the isolated source archive
197
+ shell: bash
198
+ run: |
199
+ mkdir build/source-check
200
+ tar -xzf dist/doc2struct-*.tar.gz -C build/source-check --strip-components=1
201
+ python -m pip install ./build/source-check
202
+ python build_scripts/smoke_release.py --python
203
+ - uses: actions/upload-artifact@v4
204
+ with:
205
+ name: sdist
206
+ path: dist/*.tar.gz
207
+ if-no-files-found: error
208
+
209
+ verify-python:
210
+ needs: [wheels, native, sdist]
211
+ runs-on: ubuntu-24.04
212
+ steps:
213
+ - uses: actions/setup-python@v5
214
+ with:
215
+ python-version: "3.14"
216
+ - uses: actions/download-artifact@v4
217
+ with:
218
+ pattern: wheels-*
219
+ merge-multiple: true
220
+ path: dist
221
+ - uses: actions/download-artifact@v4
222
+ with:
223
+ name: sdist
224
+ path: dist
225
+ - run: python -m pip install twine
226
+ - run: python -m twine check --strict dist/*
227
+
228
+ release-assets:
229
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
230
+ needs: verify-python
231
+ runs-on: ubuntu-24.04
232
+ permissions:
233
+ contents: write
234
+ steps:
235
+ - uses: actions/download-artifact@v4
236
+ with:
237
+ pattern: native-*
238
+ merge-multiple: true
239
+ path: artifacts
240
+ - uses: actions/download-artifact@v4
241
+ with:
242
+ pattern: wheels-*
243
+ merge-multiple: true
244
+ path: artifacts
245
+ - uses: actions/download-artifact@v4
246
+ with:
247
+ name: sdist
248
+ path: artifacts
249
+ - name: Write release checksums
250
+ shell: python
251
+ run: |
252
+ import hashlib, pathlib
253
+ files = sorted(pathlib.Path('artifacts').iterdir())
254
+ lines = [hashlib.sha256(p.read_bytes()).hexdigest() + ' ' + p.name for p in files]
255
+ pathlib.Path('artifacts/SHA256SUMS').write_text('\n'.join(lines) + '\n')
256
+ - name: Publish GitHub release downloads
257
+ env:
258
+ GH_TOKEN: ${{ github.token }}
259
+ GH_REPO: ${{ github.repository }}
260
+ RELEASE_TAG: ${{ github.ref_name }}
261
+ run: |
262
+ if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
263
+ gh release upload "$RELEASE_TAG" artifacts/* --clobber
264
+ else
265
+ gh release create "$RELEASE_TAG" --verify-tag --generate-notes artifacts/*
266
+ fi
267
+
268
+ publish-pypi:
269
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
270
+ needs: [release-assets]
271
+ runs-on: ubuntu-24.04
272
+ environment:
273
+ name: pypi
274
+ url: https://pypi.org/p/doc2struct
275
+ permissions:
276
+ id-token: write
277
+ steps:
278
+ - uses: actions/download-artifact@v4
279
+ with:
280
+ pattern: wheels-*
281
+ merge-multiple: true
282
+ path: dist
283
+ - uses: actions/download-artifact@v4
284
+ with:
285
+ name: sdist
286
+ path: dist
287
+ # Configure doc2struct's PyPI Trusted Publisher for this repository,
288
+ # workflow release.yml, environment pypi. No long-lived API token needed.
289
+ - uses: pypa/gh-action-pypi-publish@release/v1
290
+ with:
291
+ skip-existing: true
@@ -0,0 +1,41 @@
1
+ # python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyd
5
+ *.so
6
+ !c/vendor/pdfium/runtime/**/*.so
7
+ python/_native_source/
8
+ python/src/doc2struct/_pdfium/
9
+ *.egg-info/
10
+ build/
11
+ dist/
12
+ .venv/
13
+ venv/
14
+ .pytest_cache/
15
+
16
+ # local environment
17
+ .env
18
+ .env.*
19
+ !.env.example
20
+
21
+ # native build outputs
22
+ *.o
23
+ *.obj
24
+ *.a
25
+ *.lib
26
+ *.pdb
27
+ *.ilk
28
+ *.exp
29
+ cmake-build-*/
30
+
31
+ # run.py output
32
+ testing/
33
+
34
+ # local filing data
35
+ data/
36
+
37
+ # editor / os
38
+ .vscode/
39
+ .idea/
40
+ .DS_Store
41
+ Thumbs.db
@@ -0,0 +1,26 @@
1
+ cmake_minimum_required(VERSION 3.18)
2
+ project(doc2struct LANGUAGES C)
3
+ option(DOC2STRUCT_BUILD_PYTHON "Build the Python extension" OFF)
4
+ add_subdirectory(c)
5
+
6
+ if(DOC2STRUCT_BUILD_PYTHON)
7
+ find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
8
+ Python_add_library(_native MODULE WITH_SOABI python/native/module.c)
9
+ target_link_libraries(_native PRIVATE doc2struct::doc2struct)
10
+ set_target_properties(_native PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED YES)
11
+ if(MSVC)
12
+ target_compile_options(_native PRIVATE /utf-8)
13
+ endif()
14
+ get_filename_component(PDFIUM_DIRECTORY "${PDFIUM_LIBRARY}" DIRECTORY)
15
+ set(PDFIUM_METADATA "${PDFIUM_DIRECTORY}/version.json")
16
+ execute_process(COMMAND "${Python_EXECUTABLE}"
17
+ "${CMAKE_CURRENT_SOURCE_DIR}/build_scripts/validate_pdfium.py"
18
+ "${PDFIUM_LIBRARY}" --licenses "${PDFIUM_LICENSE_DIR}" RESULT_VARIABLE PDFIUM_VALIDATION)
19
+ if(NOT PDFIUM_VALIDATION EQUAL 0)
20
+ message(FATAL_ERROR "PDFium runtime validation failed")
21
+ endif()
22
+ install(TARGETS _native LIBRARY DESTINATION doc2struct COMPONENT python RUNTIME DESTINATION doc2struct COMPONENT python)
23
+ install(FILES "${PDFIUM_LIBRARY}" DESTINATION doc2struct/_pdfium RENAME "doc2struct_pdfium${CMAKE_SHARED_LIBRARY_SUFFIX}" COMPONENT python)
24
+ install(FILES "${PDFIUM_METADATA}" DESTINATION doc2struct/_pdfium COMPONENT python)
25
+ install(DIRECTORY "${PDFIUM_LICENSE_DIR}/" DESTINATION doc2struct/_pdfium/licenses COMPONENT python)
26
+ endif()
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 John Friedman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.