Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ca95d2

Browse files
committed
Update setup.py tasks for new directory structure
1 parent c247ab5 commit 1ca95d2

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

plotly-package/setup.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212

1313
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'))
1617

1718
npm_path = os.pathsep.join([
1819
os.path.join(node_root, 'node_modules', '.bin'),
@@ -22,16 +23,16 @@
2223

2324
# Load plotly.js version from js/package.json
2425
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:
2628
package_json = json.load(f)
2729
version = package_json['dependencies']['plotly.js']
2830

2931
return version
3032

3133

3234
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:
3536
return f.read()
3637

3738

@@ -157,20 +158,23 @@ def overwrite_schema(url):
157158
import requests
158159
req = requests.get(url)
159160
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:
161163
f.write(req.content)
162164

163165

164166
def overwrite_bundle(url):
165167
import requests
166168
req = requests.get(url)
167169
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:
169172
f.write(req.content)
170173

171174

172175
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:
174178
f.write("""\
175179
# DO NOT EDIT
176180
# This file is generated by the updatebundle setup.py command
@@ -179,7 +183,8 @@ def overwrite_plotlyjs_version_file(plotlyjs_version):
179183

180184

181185
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:
183188
f.write("""\
184189
# This file is generated by the updateplotlywidgetversion setup.py command
185190
# for automated dev builds
@@ -364,8 +369,7 @@ def run(self):
364369
package_json = json.load(f)
365370

366371
# 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)
369373
pieces['dirty'] = False
370374
widget_ver = render(pieces, 'pep440')['version']
371375

0 commit comments

Comments
 (0)