20
20
21
21
here = os .path .dirname (os .path .abspath (__file__ ))
22
22
project_root = os .path .dirname (os .path .dirname (os .path .dirname (here )))
23
- node_root = os .path .join (here , "js" )
23
+ jupyterlab_extension_root = os .path .join (project_root , "javascript" , "jupyterlab-plotly" )
24
+ widget_root = os .path .join (here , "js" )
24
25
is_repo = os .path .exists (os .path .join (project_root , ".git" ))
25
26
26
27
npm_path = os .pathsep .join (
27
28
[
28
- os .path .join (node_root , "node_modules" , ".bin" ),
29
+ os .path .join (jupyterlab_extension_root , "node_modules" , ".bin" ),
29
30
os .environ .get ("PATH" , os .defpath ),
30
31
]
31
32
)
@@ -131,9 +132,12 @@ class NPM(Command):
131
132
132
133
user_options = []
133
134
134
- node_modules = os .path .join (node_root , "node_modules" )
135
+ node_modules = os .path .join (jupyterlab_extension_root , "node_modules" )
135
136
136
137
targets = [
138
+ os .path .join (here , "jupyterlab_plotly" , "nbextension" , "extension.js" ),
139
+ os .path .join (here , "jupyterlab_plotly" , "nbextension" , "index.js" ),
140
+ os .path .join (here , "jupyterlab_plotly" , "labextension" , "package.json" ),
137
141
os .path .join (here , "plotly" , "bundle.js" ),
138
142
]
139
143
@@ -158,11 +162,6 @@ def has_npm(self):
158
162
except :
159
163
return False
160
164
161
- def should_run_npm_install (self ):
162
- package_json = os .path .join (node_root , "package.json" )
163
- node_modules_exists = os .path .exists (self .node_modules )
164
- return self .has_npm ()
165
-
166
165
def run (self ):
167
166
if skip_npm :
168
167
log .info ("Skipping npm-installation" )
@@ -177,28 +176,40 @@ def run(self):
177
176
env = os .environ .copy ()
178
177
env ["PATH" ] = npm_path
179
178
180
- if self .should_run_npm_install ():
179
+ if self .has_npm ():
181
180
log .info (
182
181
"Installing build dependencies with npm. This may take a while..."
183
182
)
184
183
npmName = self .get_npm_name ()
185
184
check_call (
186
185
[npmName , "install" ],
187
- cwd = node_root ,
186
+ cwd = jupyterlab_extension_root ,
187
+ stdout = sys .stdout ,
188
+ stderr = sys .stderr ,
189
+ )
190
+ check_call (
191
+ [npmName , "install" ],
192
+ cwd = widget_root ,
188
193
stdout = sys .stdout ,
189
194
stderr = sys .stderr ,
190
195
)
191
196
if self .local is not None :
192
197
plotly_archive = os .path .join (self .local , "plotly.js.tgz" )
193
198
check_call (
194
199
[npmName , "install" , plotly_archive ],
195
- cwd = node_root ,
200
+ cwd = jupyterlab_extension_root ,
196
201
stdout = sys .stdout ,
197
202
stderr = sys .stderr ,
198
203
)
204
+ check_call (
205
+ [npmName , "run" , "build:prod" ],
206
+ cwd = jupyterlab_extension_root ,
207
+ stdout = sys .stdout ,
208
+ stderr = sys .stderr ,
209
+ )
199
210
check_call (
200
211
[npmName , "run" , "build" ],
201
- cwd = node_root ,
212
+ cwd = widget_root ,
202
213
stdout = sys .stdout ,
203
214
stderr = sys .stderr ,
204
215
)
@@ -449,7 +460,7 @@ def run(self):
449
460
overwrite_schema_local (schema_uri )
450
461
451
462
# Update plotly.js url in package.json
452
- package_json_path = os .path .join (node_root , "package.json" )
463
+ package_json_path = os .path .join (jupyterlab_extension_root , "package.json" )
453
464
with open (package_json_path , "r" ) as f :
454
465
package_json = json .load (f )
455
466
@@ -504,7 +515,7 @@ def run(self):
504
515
from plotly ._version import git_pieces_from_vcs , render
505
516
506
517
# Update plotly.js url in package.json
507
- package_json_path = os .path .join (node_root , "package.json" )
518
+ package_json_path = os .path .join (jupyterlab_extension_root , "package.json" )
508
519
509
520
with open (package_json_path , "r" ) as f :
510
521
package_json = json .load (f )
0 commit comments