Unverified Commit 469ecc7b authored by Yt's avatar Yt Committed by GitHub
Browse files

python312Packages.pdf2docx: fix build (#349445)

parents 9f9c4e21 06b34fe3
Loading
Loading
Loading
Loading
+9 −20
Original line number Diff line number Diff line
@@ -2,9 +2,7 @@
  stdenv,
  lib,
  fetchFromGitHub,
  python,
  buildPythonPackage,
  imagemagick,
  pip,
  pytestCheckHook,
  pymupdf,
@@ -14,6 +12,7 @@
  opencv4,
  tkinter,
  python-docx,
  setuptools,
}:
let
  version = "0.5.8";
@@ -21,26 +20,25 @@ in
buildPythonPackage {
  pname = "pdf2docx";
  inherit version;
  format = "setuptools";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "dothinking";
    owner = "ArtifexSoftware";
    repo = "pdf2docx";
    rev = "refs/tags/v${version}";
    hash = "sha256-tMITDm2NkxWS+H/hhd2LlaPbyuI86ZKaALqqHJqb8V0=";
  };

  nativeBuildInputs = [
  build-system = [
    pip
    imagemagick
    setuptools
  ];

  pythonRemoveDeps = [ "opencv-python" ];

  preBuild = "echo '${version}' > version.txt";

  propagatedBuildInputs = [
    tkinter
  dependencies = [
    pymupdf
    fire
    fonttools
@@ -49,15 +47,6 @@ buildPythonPackage {
    python-docx
  ];

  postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
    # on linux the icon file can only be xbm format
    convert $out/${python.sitePackages}/pdf2docx/gui/icon.ico \
      $out/${python.sitePackages}/pdf2docx/gui/icon.xbm
    substituteInPlace $out/${python.sitePackages}/pdf2docx/gui/App.py \
      --replace 'icon.ico' 'icon.xbm' \
      --replace 'iconbitmap(icon_path)' "iconbitmap(f'@{icon_path}')"
  '';

  nativeCheckInputs = [ pytestCheckHook ];

  pytestFlagsArray = [
@@ -71,9 +60,9 @@ buildPythonPackage {
  meta = with lib; {
    description = "Convert PDF to DOCX";
    mainProgram = "pdf2docx";
    homepage = "https://github.com/dothinking/pdf2docx";
    changelog = "https://github.com/dothinking/pdf2docx/releases/tag/v${version}";
    license = licenses.gpl3Only;
    homepage = "https://github.com/ArtifexSoftware/pdf2docx";
    changelog = "https://github.com/ArtifexSoftware/pdf2docx/releases/tag/v${version}";
    license = licenses.agpl3Only;
    maintainers = with maintainers; [ happysalada ];
  };
}