python312Packages.kaleido: Add passthru.tests

(cherry picked from commit 46c1ce890a)
This commit is contained in:
Gavin John
2024-09-02 22:06:59 -07:00
parent 56c8ff99ce
commit 8a56d27d2a
3 changed files with 29 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
stdenv,
python,
buildPythonPackage,
callPackage,
fetchurl,
autoPatchelfHook,
bash,
@@ -96,6 +97,8 @@ buildPythonPackage rec {
#ln -s ${lato}/share/fonts/lato/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato/
'';
passthru.tests.kaleido = callPackage ./tests.nix { };
meta = {
description = "Fast static image export for web-based visualization libraries with zero dependencies";
homepage = "https://github.com/plotly/Kaleido";

View File

@@ -0,0 +1,15 @@
{
runCommand,
python,
plotly,
pandas,
kaleido,
}:
runCommand "${kaleido.pname}-tests" {
nativeBuildInputs = [
python
plotly
pandas
];
} "python3 ${./tests.py}"

View File

@@ -0,0 +1,11 @@
import plotly.express as px
import os
import os.path
out = os.environ["out"]
if not os.path.exists(out):
os.makedirs(out)
outfile = os.path.join(out, "figure.png")
fig = px.scatter(px.data.iris(), x="sepal_length", y="sepal_width", color="species")
fig.write_image(outfile, engine="kaleido")