forked from jupyter/dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
72 lines (63 loc) · 2.28 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
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
from setuptools import setup
from setuptools.command.install import install
from IPython.html.nbextensions import install_nbextension
from IPython.html.services.config import ConfigManager
VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
EXT_DIR = os.path.join(os.path.dirname(__file__), 'urth_dash_js')
SERVER_EXT_CONFIG = "c.NotebookApp.server_extensions.append('urth.dashboard.nbexts')"
class InstallCommand(install):
def run(self):
print('Installing Python module')
install.run(self)
print('Installing notebook extension')
install_nbextension(EXT_DIR, overwrite=True, user=True)
cm = ConfigManager()
print('Enabling extension for notebook')
cm.update('notebook', {"load_extensions": {'urth_dash_js/notebook/main': True}})
print('Installing notebook server extension')
fn = os.path.join(cm.profile_dir, 'ipython_notebook_config.py')
if os.path.isfile(fn):
with open(fn, 'r+') as fh:
lines = fh.read()
if SERVER_EXT_CONFIG not in lines:
fh.seek(0, 2)
fh.write('\n')
fh.write(SERVER_EXT_CONFIG)
else:
with open(fn, 'w') as fh:
fh.write('c = get_config()\n')
fh.write(SERVER_EXT_CONFIG)
# Apply version to build
VERSION = '0.1'
if os.path.isfile(VERSION_FILE):
# CI build, read metadata and append
with open(VERSION_FILE, 'r') as fh:
BUILD_INFO = fh.readline().strip()
BUILD_NUMBER, _ = BUILD_INFO.split('-')
VERSION += '.dev' + BUILD_NUMBER
else:
# Local development build
VERSION += '.dev0'
setup(
name='urth-dash-nbexts',
author='Jupyter Community',
maintainer='Jupyter Community',
description='IPython / Jupyter extensions to enable dashboard creation and deployment',
version=VERSION,
license='BSD',
platforms=['IPython Notebook 3.x'],
packages=[
'urth',
'urth.dashboard',
'urth.dashboard.nbexts',
'urth.dashboard.converter'
],
include_package_data=True,
install_requires=[],
cmdclass={
'install': InstallCommand
}
)