Skip to content

Commit

Permalink
Attempt to fix call_ctypesgen on windows+py37
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Feb 25, 2023
1 parent 9ba583e commit f1f0b28
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions setupsrc/pypdfium2_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ def get_wheel_tag(pl_name):
raise ValueError(f"Unknown platform name {pl_name}")


def run_cmd(command, cwd, capture=False, check=True, **kwargs):
def run_cmd(command, cwd, capture=False, check=True, str_cast=True, **kwargs):

print(f"{command} (cwd='{cwd}')", file=sys.stderr)
if str_cast:
command = [str(c) for c in command]

print(f"{command} (cwd={cwd!r})", file=sys.stderr)
if capture:
kwargs.update( dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT) )

Expand All @@ -204,10 +207,9 @@ def get_latest_version():
def call_ctypesgen(target_dir, include_dir):

bindings = target_dir / BindingsFileName
headers = sorted(include_dir.glob("*.h"))

# https://github.com/ctypesgen/ctypesgen/issues/160
run_cmd(["ctypesgen", "--library", "pdfium", "--runtime-libdir", ".", f"--strip-build-path={include_dir}", *headers, "-o", bindings], cwd=target_dir)
run_cmd(["ctypesgen", "--library", "pdfium", "--runtime-libdir", ".", f"--strip-build-path={include_dir}", *sorted(include_dir.glob("*.h")), "-o", bindings], cwd=target_dir)

text = bindings.read_text()
text = text.replace(str(include_dir), ".")
Expand Down

0 comments on commit f1f0b28

Please sign in to comment.