evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / development / python-modules / kaleido / default.nix
blobef889a0aa71527ffe4b7967feb418e9c70bee763
2   lib,
3   stdenv,
4   python,
5   buildPythonPackage,
6   callPackage,
7   fetchurl,
8   autoPatchelfHook,
9   bash,
10   dejavu_fonts,
11   expat,
12   fontconfig,
13   lato,
14   libGL,
15   makeWrapper,
16   nspr,
17   nss,
18   sbclPackages,
19   sqlite,
22 buildPythonPackage rec {
23   pname = "kaleido";
24   version = "0.2.1";
25   format = "wheel";
27   src =
28     {
29       # This library is so cursed that I have to use fetchurl instead of fetchPypi. I am not happy.
30       x86_64-linux = fetchurl {
31         url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux1_x86_64.whl";
32         hash = "sha256-qiHPG/HHj4+lCp99ReEAPDh709b+CnZ8+780S5W9w6g=";
33       };
34       aarch64-linux = fetchurl {
35         url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux2014_aarch64.whl";
36         hash = "sha256-hFgZhEyAgslGnZwX5CYh+/hcKyN++KhuyKhSf5i2USo=";
37       };
38       x86_64-darwin = fetchurl {
39         url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-macosx_10_11_x86_64.whl";
40         hash = "sha256-ym9z5/8AquvyhD9z8dO6zeGTDvUEEJP+drg6FXhQSac=";
41       };
42       aarch64-darwin = fetchurl {
43         url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-macosx_11_0_arm64.whl";
44         hash = "sha256-u5pdH3EDV9XUMu4kDvZlim0STD5hCTWBe0tC2px4fAU=";
45       };
46     }
47     ."${stdenv.hostPlatform.system}"
48       or (throw "Unsupported system for ${pname}: ${stdenv.hostPlatform.system}");
50   nativeBuildInputs = (lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]) ++ [
51     makeWrapper
52   ];
53   buildInputs = [
54     bash
55     dejavu_fonts
56     expat
57     fontconfig
58     lato
59     libGL
60     nspr
61     nss
62     sbclPackages.cl-dejavu
63     sqlite
64   ];
66   pythonImportsCheck = [ "kaleido" ];
68   postInstall = ''
69     # Expose kaleido binary
70     mkdir -p $out/bin
71     ln -s $out/${python.sitePackages}/kaleido/executable/bin/kaleido $out/bin/kaleido
73     # Replace bundled swiftshader with libGL
74     rm -rf $out/${python.sitePackages}/kaleido/executable/bin/swiftshader
75     ln -s ${libGL}/lib $out/${python.sitePackages}/kaleido/executable/bin/swiftshader
77     # Relace bundled libraries with nixpkgs-packaged libraries
78     rm -rf $out/${python.sitePackages}/kaleido/executable/lib
79     mkdir -p $out/${python.sitePackages}/kaleido/executable/lib
80     ln -s ${expat}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
81     ln -s ${nspr}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
82     ln -s ${nss}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
83     ln -s ${sqlite}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
85     # Replace bundled font configuration with nixpkgs-packaged font configuration
86     rm -rf $out/${python.sitePackages}/kaleido/executable/etc/fonts
87     mkdir -p $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d
88     ln -s ${fontconfig}/etc/fonts/fonts.conf $out/${python.sitePackages}/kaleido/executable/etc/fonts/
89     ls -s ${fontconfig}/etc/fonts/conf.d/* $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d/
90     ln -s ${sbclPackages.cl-dejavu}/dejavu-fonts-ttf-2.37/fontconfig/* $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d/
92     # Replace bundled fonts with nixpkgs-packaged fonts
93     # Currently this causes an issue where the fonts aren't found. I'm not sure why, so I'm leaving this commented out for now.
94     #rm -rf $out/${python.sitePackages}/kaleido/executable/xdg/fonts
95     #mkdir -p $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato
96     #ln -s ${dejavu_fonts}/share/fonts/truetype/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu/
97     #ln -s ${lato}/share/fonts/lato/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato/
98   '';
100   passthru.tests = lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) {
101     kaleido = callPackage ./tests.nix { };
102   };
104   meta = {
105     description = "Fast static image export for web-based visualization libraries with zero dependencies";
106     homepage = "https://github.com/plotly/Kaleido";
107     changelog = "https://github.com/plotly/Kaleido/releases";
108     platforms = [
109       "x86_64-linux"
110       "x86_64-darwin"
111       "aarch64-linux"
112       "aarch64-darwin"
113     ];
114     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; # Trust me, I'm not happy. But after literal hours of trying to reverse-engineer their build system and getting nowhere, I'll use the stupid binaries >:(
115     license = lib.licenses.mit;
116     maintainers = with lib.maintainers; [ pandapip1 ];
117   };