22 buildPythonPackage rec {
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=";
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=";
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=";
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=";
47 ."${stdenv.hostPlatform.system}"
48 or (throw "Unsupported system for ${pname}: ${stdenv.hostPlatform.system}");
50 nativeBuildInputs = (lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]) ++ [
62 sbclPackages.cl-dejavu
66 pythonImportsCheck = [ "kaleido" ];
69 # Expose kaleido binary
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/
100 passthru.tests = lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) {
101 kaleido = callPackage ./tests.nix { };
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";
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 ];