11
11
12
12
13
13
here = os .path .dirname (os .path .abspath (__file__ ))
14
- node_root = os .path .join (here , 'js' )
15
- is_repo = os .path .exists (os .path .join (here , '.git' ))
14
+ project_root = os .path .dirname (here )
15
+ node_root = os .path .join (project_root , 'js' )
16
+ is_repo = os .path .exists (os .path .join (project_root , '.git' ))
16
17
17
18
npm_path = os .pathsep .join ([
18
19
os .path .join (node_root , 'node_modules' , '.bin' ),
22
23
23
24
# Load plotly.js version from js/package.json
24
25
def plotly_js_version ():
25
- with open ('js/package.json' , 'rt' ) as f :
26
+ path = os .path .join (project_root , 'js' , 'package.json' )
27
+ with open (path , 'rt' ) as f :
26
28
package_json = json .load (f )
27
29
version = package_json ['dependencies' ]['plotly.js' ]
28
30
29
31
return version
30
32
31
33
32
34
def readme ():
33
- parent_dir = os .path .dirname (os .path .realpath (__file__ ))
34
- with open (os .path .join (parent_dir , 'README.md' )) as f :
35
+ with open (os .path .join (here , 'README.md' )) as f :
35
36
return f .read ()
36
37
37
38
@@ -157,20 +158,23 @@ def overwrite_schema(url):
157
158
import requests
158
159
req = requests .get (url )
159
160
assert req .status_code == 200
160
- with open ('plotly/package_data/plot-schema.json' , 'wb' ) as f :
161
+ path = os .path .join (here , 'codegen' , 'resources' , 'plot-schema.json' )
162
+ with open (path , 'wb' ) as f :
161
163
f .write (req .content )
162
164
163
165
164
166
def overwrite_bundle (url ):
165
167
import requests
166
168
req = requests .get (url )
167
169
assert req .status_code == 200
168
- with open ('plotly/package_data/plotly.min.js' , 'wb' ) as f :
170
+ path = os .path .join (here , 'plotly' , 'package_data' , 'plotly.min.js' )
171
+ with open (path , 'wb' ) as f :
169
172
f .write (req .content )
170
173
171
174
172
175
def overwrite_plotlyjs_version_file (plotlyjs_version ):
173
- with open ('plotly/offline/_plotlyjs_version.py' , 'w' ) as f :
176
+ path = os .path .join (here , 'plotly' , 'offline' , '_plotlyjs_version.py' )
177
+ with open (path , 'w' ) as f :
174
178
f .write ("""\
175
179
# DO NOT EDIT
176
180
# This file is generated by the updatebundle setup.py command
@@ -179,7 +183,8 @@ def overwrite_plotlyjs_version_file(plotlyjs_version):
179
183
180
184
181
185
def overwrite_plotlywidget_version_file (version ):
182
- with open ('plotly/_widget_version.py' , 'w' ) as f :
186
+ path = os .path .join (here , 'plotly' , '_widget_version.py' )
187
+ with open (path , 'w' ) as f :
183
188
f .write ("""\
184
189
# This file is generated by the updateplotlywidgetversion setup.py command
185
190
# for automated dev builds
@@ -364,8 +369,7 @@ def run(self):
364
369
package_json = json .load (f )
365
370
366
371
# Replace version with bundle url
367
- root = os .path .dirname (os .path .realpath (__file__ ))
368
- pieces = git_pieces_from_vcs ('widget-v' , root , False )
372
+ pieces = git_pieces_from_vcs ('widget-v' , project_root , False )
369
373
pieces ['dirty' ] = False
370
374
widget_ver = render (pieces , 'pep440' )['version' ]
371
375
0 commit comments