-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
python312Packages.kaleido: init at 0.2.1 #339136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
natsukium
merged 5 commits into
NixOS:master
from
Pandapip1:init-python3packages-kaleido
Sep 5, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25ad2d1
python312Packages.kaleido: init at 0.2.1
Pandapip1 534c90d
python312Packages.plotly: Add kaleido to dependencies
Pandapip1 46c1ce8
python312Packages.kaleido: Add passthru.tests
Pandapip1 6c98676
python312Packages.plotly: adopt
Pandapip1 7edc3b6
python312Packages.kaleido: mark as broken on darwin
Pandapip1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| { | ||
| lib, | ||
| stdenv, | ||
| python, | ||
| buildPythonPackage, | ||
| callPackage, | ||
| fetchurl, | ||
| autoPatchelfHook, | ||
| bash, | ||
| dejavu_fonts, | ||
| expat, | ||
| fontconfig, | ||
| lato, | ||
| libGL, | ||
| makeWrapper, | ||
| nspr, | ||
| nss, | ||
| sbclPackages, | ||
| sqlite, | ||
| }: | ||
|
|
||
| buildPythonPackage rec { | ||
| pname = "kaleido"; | ||
| version = "0.2.1"; | ||
| format = "wheel"; | ||
|
|
||
| src = | ||
| { | ||
| # This library is so cursed that I have to use fetchurl instead of fetchPypi. I am not happy. | ||
| x86_64-linux = fetchurl { | ||
| url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux1_x86_64.whl"; | ||
| hash = "sha256-qiHPG/HHj4+lCp99ReEAPDh709b+CnZ8+780S5W9w6g="; | ||
| }; | ||
| aarch64-linux = fetchurl { | ||
| url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux2014_aarch64.whl"; | ||
| hash = "sha256-hFgZhEyAgslGnZwX5CYh+/hcKyN++KhuyKhSf5i2USo="; | ||
| }; | ||
| x86_64-darwin = fetchurl { | ||
| url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-macosx_10_11_x86_64.whl"; | ||
| hash = "sha256-ym9z5/8AquvyhD9z8dO6zeGTDvUEEJP+drg6FXhQSac="; | ||
| }; | ||
| aarch64-darwin = fetchurl { | ||
| url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-macosx_11_0_arm64.whl"; | ||
| hash = "sha256-u5pdH3EDV9XUMu4kDvZlim0STD5hCTWBe0tC2px4fAU="; | ||
| }; | ||
| } | ||
| ."${stdenv.hostPlatform.system}" | ||
| or (throw "Unsupported system for ${pname}: ${stdenv.hostPlatform.system}"); | ||
|
|
||
| nativeBuildInputs = (lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]) ++ [ | ||
| makeWrapper | ||
| ]; | ||
| buildInputs = [ | ||
| bash | ||
| dejavu_fonts | ||
| expat | ||
| fontconfig | ||
| lato | ||
| libGL | ||
| nspr | ||
| nss | ||
| sbclPackages.cl-dejavu | ||
| sqlite | ||
| ]; | ||
|
|
||
| pythonImportsCheck = [ "kaleido" ]; | ||
|
|
||
| postInstall = '' | ||
| # Expose kaleido binary | ||
| mkdir -p $out/bin | ||
| ln -s $out/${python.sitePackages}/kaleido/executable/bin/kaleido $out/bin/kaleido | ||
|
|
||
| # Replace bundled swiftshader with libGL | ||
| rm -rf $out/${python.sitePackages}/kaleido/executable/bin/swiftshader | ||
| ln -s ${libGL}/lib $out/${python.sitePackages}/kaleido/executable/bin/swiftshader | ||
|
|
||
| # Relace bundled libraries with nixpkgs-packaged libraries | ||
| rm -rf $out/${python.sitePackages}/kaleido/executable/lib | ||
| mkdir -p $out/${python.sitePackages}/kaleido/executable/lib | ||
| ln -s ${expat}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/ | ||
| ln -s ${nspr}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/ | ||
| ln -s ${nss}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/ | ||
| ln -s ${sqlite}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/ | ||
|
|
||
| # Replace bundled font configuration with nixpkgs-packaged font configuration | ||
| rm -rf $out/${python.sitePackages}/kaleido/executable/etc/fonts | ||
| mkdir -p $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d | ||
| ln -s ${fontconfig}/etc/fonts/fonts.conf $out/${python.sitePackages}/kaleido/executable/etc/fonts/ | ||
| ls -s ${fontconfig}/etc/fonts/conf.d/* $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d/ | ||
| ln -s ${sbclPackages.cl-dejavu}/dejavu-fonts-ttf-2.37/fontconfig/* $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d/ | ||
|
|
||
| # Replace bundled fonts with nixpkgs-packaged fonts | ||
| # 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. | ||
| #rm -rf $out/${python.sitePackages}/kaleido/executable/xdg/fonts | ||
| #mkdir -p $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/lato | ||
| #ln -s ${dejavu_fonts}/share/fonts/truetype/* $out/${python.sitePackages}/kaleido/executable/xdg/fonts/truetype/dejavu/ | ||
| #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"; | ||
| changelog = "https://github.com/plotly/Kaleido/releases"; | ||
| platforms = [ | ||
| "x86_64-linux" | ||
| "x86_64-darwin" | ||
| "aarch64-linux" | ||
| "aarch64-darwin" | ||
| ]; | ||
| 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 >:( | ||
|
||
| license = lib.licenses.mit; | ||
| maintainers = with lib.maintainers; [ pandapip1 ]; | ||
| broken = stdenv.isDarwin; # Tests fail on darwin for some reason | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| runCommand, | ||
| python, | ||
| plotly, | ||
| pandas, | ||
| kaleido, | ||
| }: | ||
|
|
||
| runCommand "${kaleido.pname}-tests" { | ||
| nativeBuildInputs = [ | ||
| python | ||
| plotly | ||
| pandas | ||
| ]; | ||
| } "python3 ${./tests.py}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.