From 70342c4e73a9d9671a6f0185bc32ae17eb281c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Tue, 8 Jun 2021 10:39:04 +0200 Subject: [PATCH] Add prebuilt assets when installing from sdist Fixes #3230 --- packages/python/plotly/setup.py | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/packages/python/plotly/setup.py b/packages/python/plotly/setup.py index 67298e6e0c8..4d9c2420328 100644 --- a/packages/python/plotly/setup.py +++ b/packages/python/plotly/setup.py @@ -33,6 +33,26 @@ # Ensure the folder exists when we will look for files in it os.makedirs(labstatic) +prebuilt_assets = [ + ( + "share/jupyter/labextensions/jupyterlab-plotly", + ["jupyterlab_plotly/labextension/package.json",], + ), + ( + "share/jupyter/labextensions/jupyterlab-plotly/static", + [os.path.join(labstatic, f) for f in os.listdir(labstatic)], + ), + ( + "share/jupyter/nbextensions/jupyterlab-plotly", + [ + "jupyterlab_plotly/nbextension/extension.js", + "jupyterlab_plotly/nbextension/index.js", + "jupyterlab_plotly/nbextension/index.js.LICENSE.txt", + ], + ), +] + + if "--skip-npm" in sys.argv or os.environ.get("SKIP_NPM") is not None: print("Skipping npm install as requested.") skip_npm = True @@ -68,6 +88,7 @@ def run(self): if not is_repo and all(os.path.exists(t) for t in jsdeps.targets): # sdist, nothing to do command.run(self) + self.distribution.data_files.extend(prebuilt_assets) return try: @@ -94,26 +115,7 @@ def update_package_data(distribution): # JS assets will not be present if we are skip npm build if not skip_npm: - distribution.data_files.extend( - [ - ( - "share/jupyter/labextensions/jupyterlab-plotly", - ["jupyterlab_plotly/labextension/package.json",], - ), - ( - "share/jupyter/labextensions/jupyterlab-plotly/static", - [os.path.join(labstatic, f) for f in os.listdir(labstatic)], - ), - ( - "share/jupyter/nbextensions/jupyterlab-plotly", - [ - "jupyterlab_plotly/nbextension/extension.js", - "jupyterlab_plotly/nbextension/index.js", - "jupyterlab_plotly/nbextension/index.js.LICENSE.txt", - ], - ), - ] - ) + distribution.data_files.extend(prebuilt_assets) # re-init build_py options which load package_data build_py.finalize_options()