Files
nixpkgs/pkgs/development/python-modules/pdf2docx/default.nix
T
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

80 lines
1.7 KiB
Nix

{
stdenv,
lib,
fetchFromGitHub,
python,
buildPythonPackage,
imagemagick,
pip,
pytestCheckHook,
pymupdf,
fire,
fonttools,
numpy,
opencv4,
tkinter,
python-docx,
}:
let
version = "0.5.8";
in
buildPythonPackage {
pname = "pdf2docx";
inherit version;
format = "setuptools";
src = fetchFromGitHub {
owner = "dothinking";
repo = "pdf2docx";
rev = "refs/tags/v${version}";
hash = "sha256-tMITDm2NkxWS+H/hhd2LlaPbyuI86ZKaALqqHJqb8V0=";
};
nativeBuildInputs = [
pip
imagemagick
];
pythonRemoveDeps = [ "opencv-python" ];
preBuild = "echo '${version}' > version.txt";
propagatedBuildInputs = [
tkinter
pymupdf
fire
fonttools
numpy
opencv4
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 = [
"-v"
"./test/test.py::TestConversion"
];
# Test fails due to "RuntimeError: cannot find builtin font with name 'Arial'":
disabledTests = [ "test_unnamed_fonts" ];
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;
maintainers = with maintainers; [ happysalada ];
};
}