diff --git a/setupsrc/pypdfium2_setup/build_pdfium.py b/setupsrc/pypdfium2_setup/build_pdfium.py index 2c4e7d2b7..672356f27 100755 --- a/setupsrc/pypdfium2_setup/build_pdfium.py +++ b/setupsrc/pypdfium2_setup/build_pdfium.py @@ -227,7 +227,7 @@ def pack(src_libpath, v_libpdfium, destname=None): update_version(v_libpdfium) include_dir = PDFiumDir / "public" - call_ctypesgen(OutputDir, include_dir) + call_ctypesgen(OutputDir, include_dir, pl_name=Host.platform) def get_tool(name): diff --git a/setupsrc/pypdfium2_setup/packaging_base.py b/setupsrc/pypdfium2_setup/packaging_base.py index 20bf8654c..afe2f6940 100644 --- a/setupsrc/pypdfium2_setup/packaging_base.py +++ b/setupsrc/pypdfium2_setup/packaging_base.py @@ -290,7 +290,7 @@ def purge_pdfium_versions(): )) -def call_ctypesgen(target_dir, include_dir, use_v8xfa=False, guard_symbols=False): +def call_ctypesgen(target_dir, include_dir, pl_name, use_v8xfa=False, guard_symbols=False): # The commands below are tailored to our fork of ctypesgen, so make sure we have that # Import ctypesgen only in this function so it does not have to be available for other setup tasks @@ -298,7 +298,13 @@ def call_ctypesgen(target_dir, include_dir, use_v8xfa=False, guard_symbols=False assert getattr(ctypesgen, "PYPDFIUM2_SPECIFIC", False) bindings = target_dir / BindingsFileName - args = ["ctypesgen", "--library", "pdfium", "--runtime-libdirs", ".", "--no-srcinfo", f"--strip-build-path={include_dir}"] + + args = ["ctypesgen", f"--strip-build-path={include_dir}", "--no-srcinfo", "--library", "pdfium", "--runtime-libdirs", "."] + if pl_name == Host.platform: + # assuming the binary already lies in target_dir + args += ["--compile-libdirs", target_dir] + else: + args += ["--no-load-library"] if not guard_symbols: args += ["--no-symbol-guards"] if use_v8xfa: diff --git a/setupsrc/pypdfium2_setup/update_pdfium.py b/setupsrc/pypdfium2_setup/update_pdfium.py index bf71a4418..e8215121e 100755 --- a/setupsrc/pypdfium2_setup/update_pdfium.py +++ b/setupsrc/pypdfium2_setup/update_pdfium.py @@ -112,11 +112,11 @@ def generate_bindings(archives, version, full_version, use_v8, ctypesgen_kws): else: assert not v8_file.exists() - call_ctypesgen(pl_dir, build_dir/"include", use_v8xfa=use_v8, **ctypesgen_kws) + call_ctypesgen(pl_dir, build_dir/"include", pl_name=pl_name, use_v8xfa=use_v8, **ctypesgen_kws) shutil.rmtree(build_dir) -def main(platforms, version=None, robust=False, max_workers=None, use_v8=False, ctypesgen_kws=dict()): +def main(platforms, version=None, robust=False, max_workers=None, use_v8=False, ctypesgen_kws={}): if not version: version = get_latest_version()