forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
161 lines (128 loc) · 4.8 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from os.path import join as pjoin
import json
import os
import sys
# Our own imports
from setupbase import (
create_cmdclass, ensure_python, find_packages, get_version,
command_for_func, combine_commands, install_npm, HERE, run,
skip_npm, which, log
)
from setuptools import setup
from setuptools.command.develop import develop
NAME = 'jupyterlab'
DESCRIPTION = 'The JupyterLab notebook server extension.'
LONG_DESCRIPTION = """
An extensible, comprehensive Jupyter web application.
Development happens on https://github.com/jupyter/jupyterlab, with chat on
https://gitter.im/jupyterlab/jupyterlab.
"""
ensure_python(['>=3.5'])
data_files_spec = [
('share/jupyter/lab/static', '%s/static' % NAME, '**'),
('share/jupyter/lab/schemas', '%s/schemas' % NAME, '**'),
('share/jupyter/lab/themes', '%s/themes' % NAME, '**'),
('etc/jupyter/jupyter_notebook_config.d',
'jupyter-config/jupyter_notebook_config.d', 'jupyterlab.json'),
]
package_data_spec = dict()
package_data_spec[NAME] = [
'staging/*', 'staging/templates/*', 'static/**', 'tests/mock_packages/**',
'themes/**', 'schemas/**', '*.js'
]
staging = pjoin(HERE, NAME, 'staging')
npm = ['node', pjoin(staging, 'yarn.js')]
VERSION = get_version('%s/_version.py' % NAME)
def check_assets():
from distutils.version import LooseVersion
# Representative files that should exist after a successful build
targets = [
'static/package.json',
'schemas/@jupyterlab/shortcuts-extension/plugin.json',
'themes/@jupyterlab/theme-light-extension/index.css'
]
for t in targets:
if not os.path.exists(pjoin(HERE, NAME, t)):
msg = ('Missing file: %s, `build:prod` script did not complete '
'successfully' % t)
raise ValueError(msg)
if 'sdist' not in sys.argv and 'bdist_wheel' not in sys.argv:
return
target = pjoin(HERE, NAME, 'static', 'package.json')
with open(target) as fid:
version = json.load(fid)['jupyterlab']['version']
if LooseVersion(version) != LooseVersion(VERSION):
raise ValueError('Version mismatch, please run `build:update`')
cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec,
package_data_spec=package_data_spec)
cmdclass['jsdeps'] = combine_commands(
install_npm(build_cmd='build:prod', path=staging, source_dir=staging,
build_dir=pjoin(HERE, NAME, 'static'), npm=npm),
command_for_func(check_assets)
)
class JupyterlabDevelop(develop):
"""A custom develop command that runs yarn"""
def run(self):
if not skip_npm:
if not which('node'):
log.error('Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.')
return
run(npm, cwd=HERE)
develop.run(self)
# Use default develop - we can ensure core mode later if needed.
cmdclass['develop'] = JupyterlabDevelop
setup_args = dict(
name = NAME,
description = DESCRIPTION,
long_description = LONG_DESCRIPTION,
version = VERSION,
packages = find_packages(),
cmdclass = cmdclass,
author = 'Jupyter Development Team',
author_email = '[email protected]',
url = 'http://jupyter.org',
license = 'BSD',
platforms = "Linux, Mac OS X, Windows",
keywords = ['ipython', 'jupyter', 'Web'],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
)
setup_args['install_requires'] = [
'notebook>=4.3.1',
'jupyterlab_launcher>=0.13.1,<0.14.0'
]
setup_args['extras_require'] = {
'test': ['pytest', 'requests', 'pytest-check-links'],
'docs': [
'sphinx',
'recommonmark',
'sphinx_rtd_theme'
],
}
setup_args['include_package_data'] = True
setup_args['python_requires'] = '>=3.5'
# Force entrypoints with setuptools (needed for Windows, unconditional
# because of wheels)
setup_args['entry_points'] = {
'console_scripts': [
'jupyter-lab = jupyterlab.labapp:main',
'jupyter-labextension = jupyterlab.labextensions:main',
'jupyter-labhub = jupyterlab.labhubapp:main',
'jlpm = jupyterlab.jlpmapp:main',
]
}
if __name__ == '__main__':
setup(**setup_args)