forked from voila-dashboards/voila-gridstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
95 lines (81 loc) · 3.14 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from setuptools import setup, find_packages
from setuptools.command.develop import develop
import os
import sys
try:
import jupyter_core.paths as jupyter_core_paths
except:
jupyter_core_paths = None
pjoin = os.path.join
class DevelopCmd(develop):
prefix_targets = [
("nbconvert/templates", 'gridstack'),
("voila/templates", 'gridstack')
]
def run(self):
target_dir = os.path.join(sys.prefix, 'share', 'jupyter')
if '--user' in sys.prefix: # TODO: is there a better way to find out?
target_dir = jupyter_core_paths.user_dir()
target_dir = os.path.join(target_dir)
for prefix_target, name in self.prefix_targets:
source = os.path.join('share', 'jupyter', prefix_target, name)
target = os.path.join(target_dir, prefix_target, name)
target_subdir = os.path.dirname(target)
if not os.path.exists(target_subdir):
os.makedirs(target_subdir)
rel_source = os.path.relpath(os.path.abspath(source), os.path.abspath(target_subdir))
try:
os.remove(target)
except:
pass
print(rel_source, '->', target)
os.symlink(rel_source, target)
super(DevelopCmd, self).run()
def get_data_files():
""" Get all data files for the package
"""
data_files = [
('etc/jupyter/jupyter_server_config.d', ['etc/jupyter/jupyter_server_config.d/voila-gridstack.json']),
('etc/jupyter/jupyter_notebook_config.d', ['etc/jupyter/jupyter_notebook_config.d/voila-gridstack.json']),
('etc/jupyter/nbconfig/notebook.d', ['etc/jupyter/nbconfig/notebook.d/voila-gridstack.json']),
('share/jupyter/nbextensions/voila-gridstack', ['voila-gridstack/static/extension.js',
'voila-gridstack/static/voila-gridstack.js',
'voila-gridstack/static/voila-gridstack.css',
'voila-gridstack/static/gridstack.js',
'voila-gridstack/static/gridstack.jqueryUI_require.js'
])
]
# Add all the templates
for root, dirs, files in os.walk('share'):
root_files = [os.path.join(root, i) for i in files]
data_files.append((root, root_files))
return data_files
setup_args = {
'name': 'voila-gridstack',
'version': '0.0.9',
'packages': find_packages(),
'data_files': get_data_files(),
'package_data': {
'voila-gridstack': [
'static/*'
]
},
'install_requires': [
'voila==0.2.0a1'
],
'extras_require': {
'test': [
'pytest',
'pytest-tornasync',
'lxml'
]
},
'author': 'Voila Development team',
'author_email': '[email protected]',
'url': 'https://github.com/voila-dashboards/voila-gridstack/',
'cmdclass': {
'develop': DevelopCmd,
} if jupyter_core_paths else {},
}
if __name__ == '__main__':
setup(**setup_args)