You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Will be tagged as not python specific by our setup.py. inputs.cibw_py_ver only controls the version used at build time. Could also use `*`, then cibuildwheel would build with the oldest supported version, and walk through the others but skip because a compatible wheel is around already.
Copy file name to clipboardExpand all lines: .github/workflows/conda.yaml
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ on:
15
15
default: 'latest'
16
16
type: string
17
17
new_only:
18
-
# only with package == "raw", ignored otherwise (actually the default should be false in that case, but I don't know if GH supports dynamic defaults depending on other inputs)
18
+
# only with package == "raw", ignored otherwise (actually the default should be false in that case, but don't know if GH supports dynamic defaults depending on other inputs)
19
19
default: true
20
20
type: boolean
21
21
test:
@@ -95,6 +95,7 @@ jobs:
95
95
fail-fast: false
96
96
matrix:
97
97
# NOTE On GH actions, macOS <=13 is Intel, whereas macOS >=14 will be ARM64
98
+
# Can't test 'windows-11-arm' because setup-miniconda doesn't support it AOTW
# Google's toolchain doesn't seem to run on Linux/Windows arm64 natively. The toolchain-free build (or cross-compilation from x86_64) should work, though.
Copy file name to clipboardExpand all lines: README.md
+66-8Lines changed: 66 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ This project comes with two scripts to automate the build process: `build_toolch
142
142
-`build_toolchained` is based on the build instructions in pdfium's Readme, and uses Google's toolchain (this means foreign binaries and sysroots). This results in a heavy checkout process that may take a lot of time and space. By default, this script will use vendored libraries, but you can also pass `--use-syslibs` to try to use system libraries. An advantage of the toolchain is its powerful cross-compilation support (including symbol reversioning).
143
143
-`build_native` is an attempt to address some shortcomings of the toolchained build (mainly a bloated checkout process, and lack of portability). It is tailored towards native compilation, and uses system tools and libraries (including the system's GCC compiler), which must be installed by the caller beforehand. This script should theoretically work on arbitrary Linux architectures. As a drawback, this process is not supported or even documented upstream, so it might be hard to maintain.
144
144
145
-
You can also set `PDFIUM_PLATFORM` to `sourcebuild-native` or `sourcebuild-toolchained` to trigger either build script through setup.
145
+
You can also set `PDFIUM_PLATFORM` to `sourcebuild-native` or `sourcebuild-toolchained` to trigger either build script through setup, and pass command-line flags with `$BUILD_PARAMS`.
146
146
However, for simplicity, both scripts/subtargets share just `sourcebuild` as staging directory.
> By default, the build scripts will create separate DLLs for vendored dependency libraries (e.g. `abseil`). However, if you want to bundle everything into a single DLL, pass `--single-lib`.
185
195
196
+
> [!NOTE]
197
+
> The native sourcebuild currently supports Linux (or similar).
198
+
> macOS and Windows are not handled, as we do not have access to these systems, and working over CI did not turn out feasible – use the toolchain-based build for now.
199
+
> Community help / pull requests to extend platform support would be welcome.
200
+
201
+
##### cibuildwheel
202
+
203
+
The native sourcebuild can be run through cibuildwheel. For targets configured in our [`pyproject.toml`](./pyproject.toml), the basic invocation is as simple as p.ex.
204
+
```bash
205
+
CIBW_BUILD="cp311-manylinux_x86_64" cibuildwheel
206
+
```
207
+
208
+
See also our [cibuildwheel workflow](.github/workflows/cibuildwheel.yaml).
209
+
For more options, see the [upstream documentation](https://cibuildwheel.pypa.io/en/stable/options).
210
+
211
+
Note that, for Linux, cibuildwheel requires Docker. On the author's version of Fedora, it can be installed as follows:
212
+
```bash
213
+
sudo dnf in moby-engine # this provides the docker command
214
+
sudo systemctl start docker
215
+
sudo systemctl enable docker
216
+
sudo usermod -aG docker $USER
217
+
# then reboot (re-login might also suffice)
218
+
```
219
+
For other ways of installing Docker, refer to the cibuildwheel docs ([Setup](https://cibuildwheel.pypa.io/en/stable/setup/), [Platforms](https://cibuildwheel.pypa.io/en/stable/platforms/)) and the links therein.
220
+
221
+
> [!WARNING]
222
+
> cibuildwheel copies the project directory into a container, not taking `.gitignore` rules into account.
223
+
> Thus, it is advisable to make a fresh checkout of pypdfium2 before running cibuildwheel.
224
+
> In particular, a toolchained checkout of pdfium within pypdfium2 is problematic, and will cause a halt on the `Copying project into container...` step.
225
+
> For development, make sure the fresh checkout is in sync with the working copy.
226
+
186
227
##### Android (Termux)
187
228
188
229
The native build may also work on Android with Termux in principle.
@@ -310,7 +351,7 @@ Disclaimer: As it is hard to keep up with constantly evolving setup code, it is
310
351
+ If unset or `auto`, the host platform is detected and a corresponding binary will be selected.
311
352
+ If an explicit platform identifier (e.g. `linux_x64`, `darwin_arm64`, ...), binaries for the requested platform will be used.[^platform_ids]
312
353
+ If `system-search`, look for and bind against system-provided pdfium instead of embedding a binary. If just `system`, consume existing bindings from `data/system/`.
313
-
+ If `sourcebuild`, binary and bindings will be taken from `data/sourcebuild/`, assuming a prior run of the native or toolchained build scripts. `sourcebuild-native` or `sourcebuild-toolchained` can also be used to trigger either build through setup. However, triggering on the caller side is preferred as this allows to pass custom options.
354
+
+ If `sourcebuild`, binary and bindings will be taken from `data/sourcebuild/`, assuming a prior run of the native or toolchained build scripts. `sourcebuild-native` or `sourcebuild-toolchained` can also be used to trigger either build through setup (use `$BUILD_PARAMS`to pass custom options).
314
355
+ If `sdist`, no platform-specific files will be included, so as to create a source distribution.
315
356
316
357
*`$PYPDFIUM_MODULES=[raw,helpers]` defines the modules to include. Metadata adapts dynamically.
@@ -954,7 +995,6 @@ Additionally, one doc build can also be hosted on [GitHub Pages](https://pypdfiu
954
995
It is implemented with a CI workflow, which is supposed to be triggered automatically on release.
955
996
This provides us with full control over build env and used commands, whereas RTD may be less liberal in this regard.
956
997
957
-
958
998
### Testing
959
999
960
1000
pypdfium2 contains a small test suite to verify the library's functionality. It is written with [pytest](https://github.com/pytest-dev/pytest/):
[^testing_corpora]: For instance, one could use the testing corpora of open-source PDF libraries (pdfium, pikepdf/ocrmypdf, mupdf/ghostscript, tika/pdfbox, pdfjs, ...)
986
1026
1027
+
### Adding a new workflow
1028
+
1029
+
When writing a new workflow, it is usually desirable to test in a branch first before merging into main.
1030
+
However, new workflows from branches cannot be dispatched from the GitHub Actions panel yet. That's why you'll want to use the [`gh`](https://cli.github.com/) command-line tool, as follows:
1031
+
```bash
1032
+
gh workflow run $WORKFLOW_NAME.yaml --ref $MY_BRANCH
1033
+
```
1034
+
If inputs are needed, JSON can be used
1035
+
```bash
1036
+
echo'{"my_json_info":1, "my_var":"hello"}'| gh workflow run $WORKFLOW_NAME.yaml --ref $MY_BRANCH --json
0 commit comments