Skip to content

Commit 70342c4

Browse files
authored
Add prebuilt assets when installing from sdist
Fixes plotly#3230
1 parent 96e4c9d commit 70342c4

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

Diff for: packages/python/plotly/setup.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@
3333
# Ensure the folder exists when we will look for files in it
3434
os.makedirs(labstatic)
3535

36+
prebuilt_assets = [
37+
(
38+
"share/jupyter/labextensions/jupyterlab-plotly",
39+
["jupyterlab_plotly/labextension/package.json",],
40+
),
41+
(
42+
"share/jupyter/labextensions/jupyterlab-plotly/static",
43+
[os.path.join(labstatic, f) for f in os.listdir(labstatic)],
44+
),
45+
(
46+
"share/jupyter/nbextensions/jupyterlab-plotly",
47+
[
48+
"jupyterlab_plotly/nbextension/extension.js",
49+
"jupyterlab_plotly/nbextension/index.js",
50+
"jupyterlab_plotly/nbextension/index.js.LICENSE.txt",
51+
],
52+
),
53+
]
54+
55+
3656
if "--skip-npm" in sys.argv or os.environ.get("SKIP_NPM") is not None:
3757
print("Skipping npm install as requested.")
3858
skip_npm = True
@@ -68,6 +88,7 @@ def run(self):
6888
if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
6989
# sdist, nothing to do
7090
command.run(self)
91+
self.distribution.data_files.extend(prebuilt_assets)
7192
return
7293

7394
try:
@@ -94,26 +115,7 @@ def update_package_data(distribution):
94115

95116
# JS assets will not be present if we are skip npm build
96117
if not skip_npm:
97-
distribution.data_files.extend(
98-
[
99-
(
100-
"share/jupyter/labextensions/jupyterlab-plotly",
101-
["jupyterlab_plotly/labextension/package.json",],
102-
),
103-
(
104-
"share/jupyter/labextensions/jupyterlab-plotly/static",
105-
[os.path.join(labstatic, f) for f in os.listdir(labstatic)],
106-
),
107-
(
108-
"share/jupyter/nbextensions/jupyterlab-plotly",
109-
[
110-
"jupyterlab_plotly/nbextension/extension.js",
111-
"jupyterlab_plotly/nbextension/index.js",
112-
"jupyterlab_plotly/nbextension/index.js.LICENSE.txt",
113-
],
114-
),
115-
]
116-
)
118+
distribution.data_files.extend(prebuilt_assets)
117119

118120
# re-init build_py options which load package_data
119121
build_py.finalize_options()

0 commit comments

Comments
 (0)