From ffb79889e9105affcf09e0a3f7e141520f831185 Mon Sep 17 00:00:00 2001
From: Gavin John <gavinnjohn@gmail.com>
Date: Wed, 11 Sep 2024 02:53:30 +0000
Subject: [PATCH 1/5] python3Packages.plotly: 5.23.0 -> 5.24.0

---
 pkgs/development/python-modules/plotly/default.nix | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix
index 38b4ed40dca2..c556d0a97c3c 100644
--- a/pkgs/development/python-modules/plotly/default.nix
+++ b/pkgs/development/python-modules/plotly/default.nix
@@ -10,12 +10,12 @@
 
 buildPythonPackage rec {
   pname = "plotly";
-  version = "5.23.0";
+  version = "5.24.0";
   pyproject = true;
 
   src = fetchPypi {
     inherit pname version;
-    hash = "sha256-ieV9ADoRYwOjTeZwCGI5E2fdVkIiq3H4Ux33Ann8AZM=";
+    hash = "sha256-6un09URIaCRCySwelxSOOtDFLwz4Ywbht22rokrdVUo=";
   };
 
   postPatch = ''

From fcfb2f3d4d4a76c8e86e39189427a6a7038d0138 Mon Sep 17 00:00:00 2001
From: Gavin John <gavinnjohn@gmail.com>
Date: Tue, 10 Sep 2024 20:22:06 -0700
Subject: [PATCH 2/5] python312Packages.plotly: switch to fetchFromGitHub

---
 pkgs/development/python-modules/plotly/default.nix | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix
index c556d0a97c3c..5b65c4f4839b 100644
--- a/pkgs/development/python-modules/plotly/default.nix
+++ b/pkgs/development/python-modules/plotly/default.nix
@@ -1,7 +1,7 @@
 {
   lib,
   buildPythonPackage,
-  fetchPypi,
+  fetchFromGitHub,
   setuptools,
   packaging,
   tenacity,
@@ -13,12 +13,16 @@ buildPythonPackage rec {
   version = "5.24.0";
   pyproject = true;
 
-  src = fetchPypi {
-    inherit pname version;
-    hash = "sha256-6un09URIaCRCySwelxSOOtDFLwz4Ywbht22rokrdVUo=";
+  src = fetchFromGitHub {
+    owner = "plotly";
+    repo = "plotly.py";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-frSUybQxst4wG8g8U43Nay9dYCUXuR3dBealwPVyFdI=";
   };
 
   postPatch = ''
+    cd packages/python/plotly
+
     substituteInPlace pyproject.toml \
       --replace-fail "\"jupyterlab~=3.0;python_version>='3.6'\"," ""
   '';

From 78f07e58ce9e5d87c1ae6dd894108827bcdffd11 Mon Sep 17 00:00:00 2001
From: Gavin John <gavinnjohn@gmail.com>
Date: Tue, 10 Sep 2024 20:39:33 -0700
Subject: [PATCH 3/5] python312Packages.plotly: remove doCheck = false

---
 pkgs/development/python-modules/plotly/default.nix | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix
index 5b65c4f4839b..deb454e0e59a 100644
--- a/pkgs/development/python-modules/plotly/default.nix
+++ b/pkgs/development/python-modules/plotly/default.nix
@@ -39,9 +39,6 @@ buildPythonPackage rec {
 
   pythonImportsCheck = [ "plotly" ];
 
-  # No tests in archive
-  doCheck = false;
-
   meta = with lib; {
     description = "Python plotting library for collaborative, interactive, publication-quality graphs";
     downloadPage = "https://github.com/plotly/plotly.py";

From ce27c04702f5fde8bbf9614daa29504e053a4046 Mon Sep 17 00:00:00 2001
From: Gavin John <gavinnjohn@gmail.com>
Date: Tue, 10 Sep 2024 20:41:18 -0700
Subject: [PATCH 4/5] python312Packages.plotly: fixup meta

---
 pkgs/development/python-modules/plotly/default.nix | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix
index deb454e0e59a..0ca2cc6c08a0 100644
--- a/pkgs/development/python-modules/plotly/default.nix
+++ b/pkgs/development/python-modules/plotly/default.nix
@@ -39,11 +39,12 @@ buildPythonPackage rec {
 
   pythonImportsCheck = [ "plotly" ];
 
-  meta = with lib; {
+  meta = {
     description = "Python plotting library for collaborative, interactive, publication-quality graphs";
-    downloadPage = "https://github.com/plotly/plotly.py";
     homepage = "https://plot.ly/python/";
-    license = with licenses; [ mit ];
-    maintainers = with maintainers; [ pandapip1 ];
+    downloadPage = "https://github.com/plotly/plotly.py";
+    changelog = "https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ pandapip1 ];
   };
 }

From 898ee40f5c679625de4f37c0e1a27aecd506b882 Mon Sep 17 00:00:00 2001
From: Gavin John <gavinnjohn@gmail.com>
Date: Mon, 7 Oct 2024 11:32:27 -0700
Subject: [PATCH 5/5] plotly: Add pytestCheckHook

---
 .../python-modules/plotly/default.nix         | 85 ++++++++++++++++++-
 1 file changed, 83 insertions(+), 2 deletions(-)

diff --git a/pkgs/development/python-modules/plotly/default.nix b/pkgs/development/python-modules/plotly/default.nix
index 0ca2cc6c08a0..8bd265181aa1 100644
--- a/pkgs/development/python-modules/plotly/default.nix
+++ b/pkgs/development/python-modules/plotly/default.nix
@@ -6,6 +6,21 @@
   packaging,
   tenacity,
   kaleido,
+  pytestCheckHook,
+  pandas,
+  requests,
+  matplotlib,
+  xarray,
+  pillow,
+  scipy,
+  psutil,
+  statsmodels,
+  ipython,
+  ipywidgets,
+  which,
+  orca,
+  nbformat,
+  scikit-image,
 }:
 
 buildPythonPackage rec {
@@ -20,9 +35,9 @@ buildPythonPackage rec {
     hash = "sha256-frSUybQxst4wG8g8U43Nay9dYCUXuR3dBealwPVyFdI=";
   };
 
-  postPatch = ''
-    cd packages/python/plotly
+  sourceRoot = "${src.name}/packages/python/plotly";
 
+  postPatch = ''
     substituteInPlace pyproject.toml \
       --replace-fail "\"jupyterlab~=3.0;python_version>='3.6'\"," ""
   '';
@@ -37,6 +52,72 @@ buildPythonPackage rec {
     kaleido
   ];
 
+  nativeCheckInputs = [
+    pytestCheckHook
+    pandas
+    requests
+    matplotlib
+    xarray
+    pillow
+    scipy
+    psutil
+    statsmodels
+    ipython
+    ipywidgets
+    which
+    orca
+    nbformat
+    scikit-image
+  ];
+
+  disabledTests = [
+    # FAILED plotly/matplotlylib/mplexporter/tests/test_basic.py::test_legend_dots - AssertionError: assert '3' == '2'
+    "test_legend_dots"
+    # FAILED plotly/matplotlylib/mplexporter/tests/test_utils.py::test_linestyle - AssertionError:
+    "test_linestyle"
+    # FAILED plotly/tests/test_io/test_to_from_plotly_json.py::test_sanitize_json[auto] - KeyError: 'template'
+    # FAILED plotly/tests/test_io/test_to_from_plotly_json.py::test_sanitize_json[json] - KeyError: 'template'
+    "test_sanitize_json"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_validate_orca - ValueError:
+    "test_validate_orca"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_orca_executable_path - ValueError:
+    "test_orca_executable_path"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_orca_version_number - ValueError:
+    "test_orca_version_number"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_ensure_orca_ping_and_proc - ValueError:
+    "test_ensure_orca_ping_and_proc"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_server_timeout_shutdown - ValueError:
+    "test_server_timeout_shutdown"
+    # FAILED plotly/tests/test_orca/test_orca_server.py::test_external_server_url - ValueError:
+    "test_external_server_url"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_simple_to_image[eps] - ValueError:
+    "test_simple_to_image"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_to_image_default[eps] - ValueError:
+    "test_to_image_default"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_write_image_string[eps] - ValueError:
+    "test_write_image_string"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_write_image_writeable[eps] - ValueError:
+    "test_write_image_writeable"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_write_image_string_format_inference[eps] - ValueError:
+    "test_write_image_string_format_inference"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_write_image_string_bad_extension_failure - assert 'must be specified as one of the followi...
+    "test_write_image_string_bad_extension_failure"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_write_image_string_bad_extension_override - ValueError:
+    "test_write_image_string_bad_extension_override"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_topojson_fig_to_image[eps] - ValueError:
+    "test_topojson_fig_to_image"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_latex_fig_to_image[eps] - ValueError:
+    "test_latex_fig_to_image"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_problematic_environment_variables[eps] - ValueError:
+    "test_problematic_environment_variables"
+    # FAILED plotly/tests/test_orca/test_to_image.py::test_invalid_figure_json - assert 'Invalid' in "\nThe orca executable is required in order to e...
+    "test_invalid_figure_json"
+    # FAILED test_init/test_dependencies_not_imported.py::test_dependencies_not_imported - AssertionError: assert 'plotly' not in {'IPython': <module>
+    "test_dependencies_not_imported"
+    # FAILED test_init/test_lazy_imports.py::test_lazy_imports - AssertionError: assert 'plotly' not in {'IPython': <module 'IPython' from '...
+    "test_lazy_imports"
+  ];
+
   pythonImportsCheck = [ "plotly" ];
 
   meta = {