summary refs log tree commit diff
path: root/pkgs/development/python-modules/weasyprint
diff options
context:
space:
mode:
authorEnno Lohmeier <enno@nerdworks.de>2019-03-11 13:27:40 +0100
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2019-05-22 11:16:50 +0200
commitde9b1003a36cef088d173391d869e775b0a0bcd3 (patch)
tree5802051297d2e704afd478e20720af5477317f5c /pkgs/development/python-modules/weasyprint
parentf4a847876cd144133a4b0e7579cb91cdba3e18de (diff)
downloadnixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar.gz
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar.bz2
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar.lz
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar.xz
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.tar.zst
nixpkgs-de9b1003a36cef088d173391d869e775b0a0bcd3.zip
pythonPackages.weasyprint: init at 45
Diffstat (limited to 'pkgs/development/python-modules/weasyprint')
-rw-r--r--pkgs/development/python-modules/weasyprint/default.nix67
-rw-r--r--pkgs/development/python-modules/weasyprint/library-paths.patch38
2 files changed, 105 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix
new file mode 100644
index 00000000000..e5597e7aea8
--- /dev/null
+++ b/pkgs/development/python-modules/weasyprint/default.nix
@@ -0,0 +1,67 @@
+{ buildPythonPackage,
+  fetchPypi,
+  cairosvg,
+  pyphen,
+  cffi,
+  cssselect,
+  lxml,
+  html5lib,
+  tinycss,
+  pygobject2,
+  glib,
+  pango,
+  fontconfig,
+  stdenv,
+  pytest,
+  pytestrunner,
+  pytest-isort,
+  pytest-flake8,
+  pytestcov,
+  isPy3k,
+  substituteAll
+}:
+
+buildPythonPackage rec {
+  pname = "weasyprint";
+  version = "45";
+  disabled = !isPy3k;
+
+  # ignore failing pytest
+  checkPhase = "pytest -k 'not test_font_stretch'";
+
+  # ignore failing flake8-test
+  prePatch = ''
+    substituteInPlace setup.cfg \
+        --replace '[tool:pytest]' '[tool:pytest]\nflake8-ignore = E501'
+  '';
+
+  checkInputs = [ pytest pytestrunner pytest-isort pytest-flake8 pytestcov ];
+
+  FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
+
+  propagatedBuildInputs = [ cairosvg pyphen cffi cssselect lxml html5lib tinycss pygobject2 ];
+
+  patches = [
+    (substituteAll {
+      src = ./library-paths.patch;
+      fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}";
+      pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
+      gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}";
+      pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
+      pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}";
+    })
+  ];
+
+  src = fetchPypi {
+    inherit version;
+    pname = "WeasyPrint";
+    sha256 = "04bf2p2x619g4q4scg8v6v57c24vwn7qckvz81rckj8clzifyr82";
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://weasyprint.org/;
+    description = "Converts web documents to PDF";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ elohmeier ];
+  };
+}
diff --git a/pkgs/development/python-modules/weasyprint/library-paths.patch b/pkgs/development/python-modules/weasyprint/library-paths.patch
new file mode 100644
index 00000000000..eabbdbdcd6e
--- /dev/null
+++ b/pkgs/development/python-modules/weasyprint/library-paths.patch
@@ -0,0 +1,38 @@
+diff --git a/weasyprint/fonts.py b/weasyprint/fonts.py
+index 377716c1..2016e01c 100644
+--- a/weasyprint/fonts.py
++++ b/weasyprint/fonts.py
+@@ -48,11 +48,8 @@ else:
+     # with OSError: dlopen() failed to load a library: cairo / cairo-2
+     # So let's hope we find the same file as cairo already did ;)
+     # Same applies to pangocairo requiring pangoft2
+-    fontconfig = dlopen(ffi, 'fontconfig', 'libfontconfig',
+-                        'libfontconfig-1.dll',
+-                        'libfontconfig.so.1', 'libfontconfig-1.dylib')
+-    pangoft2 = dlopen(ffi, 'pangoft2-1.0', 'libpangoft2-1.0-0',
+-                      'libpangoft2-1.0.so', 'libpangoft2-1.0.dylib')
++    fontconfig = dlopen(ffi, '@fontconfig@')
++    pangoft2 = dlopen(ffi, '@pangoft2@')
+ 
+     ffi.cdef('''
+         // FontConfig
+diff --git a/weasyprint/text.py b/weasyprint/text.py
+index 035074e9..08e40395 100644
+--- a/weasyprint/text.py
++++ b/weasyprint/text.py
+@@ -243,12 +243,9 @@ def dlopen(ffi, *names):
+     return ffi.dlopen(names[0])  # pragma: no cover
+ 
+ 
+-gobject = dlopen(ffi, 'gobject-2.0', 'libgobject-2.0-0', 'libgobject-2.0.so',
+-                 'libgobject-2.0.dylib')
+-pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so',
+-               'libpango-1.0.dylib')
+-pangocairo = dlopen(ffi, 'pangocairo-1.0', 'libpangocairo-1.0-0',
+-                    'libpangocairo-1.0.so', 'libpangocairo-1.0.dylib')
++gobject = dlopen(ffi, '@gobject@')
++pango = dlopen(ffi, '@pango@')
++pangocairo = dlopen(ffi, '@pangocairo@')
+ 
+ gobject.g_type_init()
+