Commit a2882f73 authored by FliegendeWurst's avatar FliegendeWurst
Browse files

python3Packages.pypdfium2: fix cross, reduce closure size

parent aac1c750
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
{
  stdenv,
  lib,
  pkgs,
  buildPythonPackage,
@@ -9,6 +10,9 @@
  numpy,
  pillow,
  pytestCheckHook,
  removeReferencesTo,
  python,
  replaceVars,
}:

let
@@ -37,6 +41,12 @@ let
      hash = "sha256-3JA7cW/xaEj/DxMHEypROwrKGo7EwUEcipRqALTvydw=";
    };

    patches = [
      (replaceVars ./fix-cc-detection.patch {
        cc = "${stdenv.cc.targetPrefix}cc";
      })
    ];

    build-system = [
      setuptools-scm
    ];
@@ -62,6 +72,10 @@ buildPythonPackage rec {
    setuptools-scm
  ];

  nativeBuildInputs = [
    removeReferencesTo
  ];

  propagatedBuildInputs = [
    pdfium-binaries
  ];
@@ -104,6 +118,11 @@ buildPythonPackage rec {
    '';
  env.PDFIUM_PLATFORM = "system:${pdfiumVersion}";

  # Remove references to stdenv in comments.
  postInstall = ''
    remove-references-to -t ${stdenv.cc.cc} $out/${python.sitePackages}/pypdfium2_raw/bindings.py
  '';

  nativeCheckInputs = [
    numpy
    pillow
+25 −0
Original line number Diff line number Diff line
diff --git a/src/ctypesgen/__main__.py b/src/ctypesgen/__main__.py
index 23ee014..2d0cfc1 100644
--- a/src/ctypesgen/__main__.py
+++ b/src/ctypesgen/__main__.py
@@ -89,17 +89,9 @@ def main_impl(args, cmd_str):
         assert _is_relative_to(args.output, args.linkage_anchor)
     
     if args.cpp:
-        assert shutil.which(args.cpp[0]), f"Given pre-processor {args.cpp[0]!r} is not available."
-    else:
-        if shutil.which("gcc"):
-            args.cpp = ["gcc", "-E"]
-        elif shutil.which("cpp"):
-            args.cpp = ["cpp"]
-        elif shutil.which("clang"):
-            args.cpp = ["clang", "-E"]
-        else:
-            raise RuntimeError("C pre-processor auto-detection failed: neither gcc nor clang available.")
-    
+        print("cpp argument ignored for nix build")
+    args.cpp = ["@cc@", "-E"]
+ 
     # Important: must not use +=, this would mutate the original object, which is problematic when default=[] is used and ctypesgen called repeatedly from within python
     args.compile_libdirs = args.compile_libdirs + args.universal_libdirs
     args.runtime_libdirs = args.runtime_libdirs + args.universal_libdirs