forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
64 lines (49 loc) · 1.89 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
#!/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 os.path as osp
import sys
from setuptools import setup
NAME = "jupyterlab"
HERE = osp.dirname(osp.abspath(__file__))
ensured_targets = [
'static/package.json',
'schemas/@jupyterlab/shortcuts-extension/shortcuts.json',
'themes/@jupyterlab/theme-light-extension/index.css'
]
ensured_targets = [osp.join(HERE, NAME, t) for t in ensured_targets]
data_files_spec = [
('share/jupyter/lab/static', f'{NAME}/static', '**'),
('share/jupyter/lab/schemas', f'{NAME}/schemas', '**'),
('share/jupyter/lab/themes', f'{NAME}/themes', '**'),
('etc/jupyter/jupyter_server_config.d',
'jupyter-config/jupyter_server_config.d', f'{NAME}.json'),
('etc/jupyter/jupyter_notebook_config.d',
'jupyter-config/jupyter_notebook_config.d', f'{NAME}.json'),
]
def post_dist():
from packaging.version import Version
from jupyter_packaging import get_version
target = pjoin(HERE, NAME, 'static', 'package.json')
with open(target) as fid:
version = json.load(fid)['jupyterlab']['version']
if Version(version) != Version(get_version(f'{NAME}/_version.py')):
raise ValueError('Version mismatch, please run `build:update`')
try:
from jupyter_packaging import wrap_installers, npm_builder, get_data_files
npm = ['node', pjoin(HERE, NAME, 'staging', 'yarn.js')]
# In develop mode, just run yarn
builder = npm_builder(build_cmd=None, npm=npm, force=True)
cmdclass = wrap_installers(post_develop=builder, post_dist=post_dist, ensured_targets=ensured_targets)
setup_args = dict(
cmdclass=cmdclass,
data_files=get_data_files(data_files_spec)
)
except ImportError:
setup_args = dict()
if __name__ == '__main__':
setup(**setup_args)