Skip to content

Commit

Permalink
[autorelease main] update 4.25.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Dec 10, 2023
1 parent 6f5df31 commit 45dbb2c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 88 deletions.
82 changes: 20 additions & 62 deletions autorelease/bindings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r"""Wrapper for fpdf_annot.h
Generated with:
/opt/hostedtoolcache/Python/3.10.13/x64/bin/ctypesgen --no-srcinfo --library pdfium --runtime-libdirs . --no-load-library --headers fpdf_annot.h fpdf_attachment.h fpdf_catalog.h fpdf_dataavail.h fpdf_doc.h fpdf_edit.h fpdf_ext.h fpdf_flatten.h fpdf_formfill.h fpdf_fwlevent.h fpdf_javascript.h fpdf_ppo.h fpdf_progressive.h fpdf_save.h fpdf_searchex.h fpdf_signature.h fpdf_structtree.h fpdf_sysfontinfo.h fpdf_text.h fpdf_thumbnail.h fpdf_transformpage.h fpdfview.h -o ~/work/pypdfium2/pypdfium2/data/bindings/bindings.py
/opt/hostedtoolcache/Python/3.10.13/x64/bin/ctypesgen --library pdfium --no-srcinfo --no-macro-guards --runtime-libdirs . --no-load-library --symbol-rules if_needed=\w+_$|\w+_t$|_\w+ --headers fpdf_annot.h fpdf_attachment.h fpdf_catalog.h fpdf_dataavail.h fpdf_doc.h fpdf_edit.h fpdf_ext.h fpdf_flatten.h fpdf_formfill.h fpdf_fwlevent.h fpdf_javascript.h fpdf_ppo.h fpdf_progressive.h fpdf_save.h fpdf_searchex.h fpdf_signature.h fpdf_structtree.h fpdf_sysfontinfo.h fpdf_text.h fpdf_thumbnail.h fpdf_transformpage.h fpdfview.h -o ~/work/pypdfium2/pypdfium2/data/bindings/bindings.py
Do not modify this file.
"""
Expand Down Expand Up @@ -59,13 +59,13 @@ def __call__(self, *args):

# End preamble

# Begin loader
# Begin loader template

import sys
import ctypes
import ctypes.util
import warnings
from pathlib import Path
import pathlib


def _find_library(libname, libdirs, allow_system_search):
Expand All @@ -77,38 +77,43 @@ def _find_library(libname, libdirs, allow_system_search):
else: # assume unix pattern or plain libname
patterns = ["lib{}.so", "{}.so", "{}"]

RELDIR = Path(__file__).parent
try:
THIS_DIR = pathlib.Path(__file__).parent
except NameError as e:
# Issue a warning if unable to determine the containing directory. After this, it's OK to just fail with NameError below if actually attempting to resolve a relative path.
assert e.name == "__file__"
warnings.warn("Bindings not stored as file, will be unable to resolve relative dirs")

for dir in libdirs:
# joining an absolute path silently discardy the path before
dir = (RELDIR / dir).resolve(strict=False)
dir = pathlib.Path(dir)
if not dir.is_absolute():
# note, joining an absolute path silently discardy the path before
dir = (THIS_DIR / dir).resolve(strict=False)
for pat in patterns:
libpath = dir / pat.format(libname)
if libpath.is_file():
return str(libpath)

if allow_system_search:
if libdirs:
warnings.warn(f"Could not find library '{libname}' in libdirs {libdirs}, searching system...")
warnings.warn(f"Could not find library '{libname}' in libdirs {libdirs}, falling back to system")
libpath = ctypes.util.find_library(libname)
if not libpath:
raise ImportError(f"Could not find library '{libname}' in system")
return libpath
else:
raise ImportError(f"Could not find library '{libname}' in libdirs {libdirs} (system search disabled)")

assert False, "unreached"

# End loader template

# Begin library load

_loader_info = dict(
libname = "pdfium",
libdirs = ['.'],
allow_system_search = True,
)
_loader_info = {'libname': 'pdfium', 'libdirs': ['.'], 'allow_system_search': True}
_loader_info["libpath"] = _find_library(**_loader_info)
assert _loader_info["libpath"], "Could not find library with config %s" % (_loader_info, )
_lib = ctypes.CDLL(_loader_info["libpath"])

# End loader
# End library load

# No modules

Expand Down Expand Up @@ -3163,53 +3168,6 @@ def FPDF_GetAValue(argb):
FPDF_MATCHCASE = 0x00000001
FPDF_MATCHWHOLEWORD = 0x00000002
FPDF_CONSECUTIVE = 0x00000004
fpdf_action_t__ = struct_fpdf_action_t__
fpdf_annotation_t__ = struct_fpdf_annotation_t__
fpdf_attachment_t__ = struct_fpdf_attachment_t__
fpdf_avail_t__ = struct_fpdf_avail_t__
fpdf_bitmap_t__ = struct_fpdf_bitmap_t__
fpdf_bookmark_t__ = struct_fpdf_bookmark_t__
fpdf_clippath_t__ = struct_fpdf_clippath_t__
fpdf_dest_t__ = struct_fpdf_dest_t__
fpdf_document_t__ = struct_fpdf_document_t__
fpdf_font_t__ = struct_fpdf_font_t__
fpdf_form_handle_t__ = struct_fpdf_form_handle_t__
fpdf_glyphpath_t__ = struct_fpdf_glyphpath_t__
fpdf_javascript_action_t = struct_fpdf_javascript_action_t
fpdf_link_t__ = struct_fpdf_link_t__
fpdf_page_t__ = struct_fpdf_page_t__
fpdf_pagelink_t__ = struct_fpdf_pagelink_t__
fpdf_pageobject_t__ = struct_fpdf_pageobject_t__
fpdf_pageobjectmark_t__ = struct_fpdf_pageobjectmark_t__
fpdf_pagerange_t__ = struct_fpdf_pagerange_t__
fpdf_pathsegment_t = struct_fpdf_pathsegment_t
fpdf_schhandle_t__ = struct_fpdf_schhandle_t__
fpdf_signature_t__ = struct_fpdf_signature_t__
fpdf_structelement_t__ = struct_fpdf_structelement_t__
fpdf_structelement_attr_t__ = struct_fpdf_structelement_attr_t__
fpdf_structtree_t__ = struct_fpdf_structtree_t__
fpdf_textpage_t__ = struct_fpdf_textpage_t__
fpdf_widget_t__ = struct_fpdf_widget_t__
fpdf_xobject_t__ = struct_fpdf_xobject_t__
FPDF_BSTR_ = struct_FPDF_BSTR_
_FS_MATRIX_ = struct__FS_MATRIX_
_FS_RECTF_ = struct__FS_RECTF_
FS_SIZEF_ = struct_FS_SIZEF_
FS_POINTF_ = struct_FS_POINTF_
_FS_QUADPOINTSF = struct__FS_QUADPOINTSF
FPDF_LIBRARY_CONFIG_ = struct_FPDF_LIBRARY_CONFIG_
FPDF_FILEHANDLER_ = struct_FPDF_FILEHANDLER_
FPDF_COLORSCHEME_ = struct_FPDF_COLORSCHEME_
_IPDF_JsPlatform = struct__IPDF_JsPlatform
_FPDF_SYSTEMTIME = struct__FPDF_SYSTEMTIME
_FPDF_FORMFILLINFO = struct__FPDF_FORMFILLINFO
_FX_FILEAVAIL = struct__FX_FILEAVAIL
_FX_DOWNLOADHINTS = struct__FX_DOWNLOADHINTS
FPDF_IMAGEOBJ_METADATA = struct_FPDF_IMAGEOBJ_METADATA
_UNSUPPORT_INFO = struct__UNSUPPORT_INFO
_IFSDK_PAUSE = struct__IFSDK_PAUSE
FPDF_FILEWRITE_ = struct_FPDF_FILEWRITE_
_FPDF_SYSFONTINFO = struct__FPDF_SYSFONTINFO
FPDF_CharsetFontMap_ = struct_FPDF_CharsetFontMap_
# No inserted files

4 changes: 2 additions & 2 deletions autorelease/record.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"pdfium": 6110,
"tag": "4.24.0"
"pdfium": 6164,
"tag": "4.25.0"
}
28 changes: 28 additions & 0 deletions docs/devel/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
# Changelog


## 4.25.0 (2023-12-10)

- Updated PDFium from `6110` to `6164`.
- Removed multiprocessing from deprecated `PdfDocument.render()` API and replaced with linear rendering. See below for more info.
- setup: Fixed blunder in headers cache logic that would cause existing headers to be always reused regardless of version. *Note, this did not affect release workflows, only local source re-installs.*
- Show path of linked binary in `pypdfium2 -v`.
- conda: Improved installation docs and channel config.
- conda/workflows: Added ability to (re-)build pypdfium2_raw bindings with any given version of pdfium. Fixes {issue}`279`.
- Made reference bindings more universal by including V8, XFA and Skia symbols. This is possible due to the dynamic symbol guards.
- Instruct ctypesgen to exclude some unused alias symbols pulled in from struct tags.
- Improved issue templates, added pull request template.
- Improved ctypesgen (pypdfium2-team fork).

#### Rationale for `PdfDocument.render()` deprecation

- The parallel rendering API unfortunately was an inherent design mistake: Multiprocessing is not meant to transfer large amounts of pixel data from workers to the main process.
- This was such a heavy drawback that it basically outweighed the parallelization, so there was no real performance advantage, only higher memory load.
- As a related problem, the worker pool produces bitmaps at an indepedent speed, regardless of where the receiving iteration might be, so bitmaps could queue up in memory, possibly causing an enormeous rise in memory consumption over time. This effect was pronounced e.g. with PNG saving via PIL, as exhibited in Facebook's `nougat` project.
- Instead, each bitmap should be processed (e.g. saved) in the job which created it. Only a minimal, final result should be sent back to the main process (e.g. a file path).
- This means we cannot reasonably provide a generic parallel renderer, instead it needs to be implemented by callers.
- Historically, note that there had been even more faults in the implementation:
* Prior to `4.22.0`, the pool was always initialized with `os.cpu_count()` processes by default, even when rendering less pages.
* Prior to `4.20.0`, a full-scale input transfer was conducted on each job (rendering it unusable with bytes input). However, this can and should be done only once on process creation.
- pypdfium2's rendering CLI cleanly re-implements parallel rendering to files. We may want to turn this into an API in the future.

**Due to the potential for serious issues as outlined above, we strongly recommend that end users update and dependants bump their minimum requirement to this version. Callers should move away from `PdfDocument.render()` and use `PdfPage.render()` instead.**


## 4.24.0 (2023-11-10)

- Updated PDFium from `6097` to `6110`.
Expand Down
24 changes: 0 additions & 24 deletions docs/devel/changelog_staging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,3 @@
<!-- List character: dash (-) -->

# Changelog for next release

- Removed multiprocessing from deprecated `PdfDocument.render()` API and replaced with linear rendering. See below for more info.
- setup: Fixed blunder in headers cache logic that would cause existing headers to be always reused regardless of version. *Note, this did not affect release workflows, only local source re-installs.*
- Show path of linked binary in `pypdfium2 -v`.
- conda: Improved installation docs and channel config.
- conda/workflows: Added ability to (re-)build pypdfium2_raw bindings with any given version of pdfium. Fixes {issue}`279`.
- Made reference bindings more universal by including V8, XFA and Skia symbols. This is possible due to the dynamic symbol guards.
- Instruct ctypesgen to exclude some unused alias symbols pulled in from struct tags.
- Improved issue templates, added pull request template.
- Improved ctypesgen (pypdfium2-team fork).

#### Rationale for `PdfDocument.render()` deprecation

- The parallel rendering API unfortunately was an inherent design mistake: Multiprocessing is not meant to transfer large amounts of pixel data from workers to the main process.
- This was such a heavy drawback that it basically outweighed the parallelization, so there was no real performance advantage, only higher memory load.
- As a related problem, the worker pool produces bitmaps at an indepedent speed, regardless of where the receiving iteration might be, so bitmaps could queue up in memory, possibly causing an enormeous rise in memory consumption over time. This effect was pronounced e.g. with PNG saving via PIL, as exhibited in Facebook's `nougat` project.
- Instead, each bitmap should be processed (e.g. saved) in the job which created it. Only a minimal, final result should be sent back to the main process (e.g. a file path).
- This means we cannot reasonably provide a generic parallel renderer, instead it needs to be implemented by callers.
- Historically, note that there had been even more faults in the implementation:
* Prior to `4.22.0`, the pool was always initialized with `os.cpu_count()` processes by default, even when rendering less pages.
* Prior to `4.20.0`, a full-scale input transfer was conducted on each job (rendering it unusable with bytes input). However, this can and should be done only once on process creation.
- pypdfium2's rendering CLI cleanly re-implements parallel rendering to files. We may want to turn this into an API in the future.

**Due to the potential for serious issues as outlined above, we strongly recommend that end users update and dependants bump their minimum requirement to this version. Callers should move away from `PdfDocument.render()` and use `PdfPage.render()` instead.**

0 comments on commit 45dbb2c

Please sign in to comment.