forked from bokeh/bokeh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
145 lines (112 loc) · 5.38 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
#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2017, Anaconda, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------
''' Setup script for Bokeh.
Two separate components comprise Bokeh:
* A JavaScript runtime BokehJS that draws and handles events in browsers
* Python "bindings" and an optional server for interacting with BokehJS
The BokehJS library is written in a mixture of CoffeeScript, TypeScript, and
pure JavaScript. This necessitates a "compilation" step to build a complete
BokehJS from these sources, and this fact makes the Bokeh setup and install
more complicated than typical pure Python projects.
In order to build BokehJS, the first step is to make sure that the "npm"
command is installed. If you are using conda, you can typically just run
conda install -c bokeh nodejs
Othewise, you can find general instructions for installing NodeJS here:
https://nodejs.org/en/download/
Once you have "npm" installed, this script can be used to build BokehJS
from the ``bokehjs`` source subdirectory, and install Bokeh into the python
source package by issuing the command:
python setup.py install --build-js
The script also supports the standard "develop" mode that setuptools offers:
python setup.py develop --build-js
It can take a few minutes for BokehJS to build, if you are not making changes
to the BokehJS source code, then you only need to build it once, the first
time. Subsequence invocations can be made to install the previously built
BokehJS from the ``bokehjs`` source subdirectoruy with the ``--install-js``
option, e.g:
python setup.py develop --install-js
It is also possible to build BokehJS "by hand" under the ``bokehjs`` source
subdirectory. In this case, to simply install the build BokehJS quickly into
the python source tree, the following command may be issued:
python setup.py --install-js
This will copy BokehJS from the ``bokehjs`` source directory, into the python
package directory, and perform no other actions.
Note that source distributions (sdists) are published with a pre-built BokehJS
included inside the python package, and do not include the ``bokehjs`` source.
The ``--build-js`` and ``-install-js`` options are not valid when running from
an sdist. They will be ignored, and warning printed.
'''
from os.path import join
from shutil import copy
import sys
from setuptools import find_packages, setup
from _setup_support import (
build_or_install_bokehjs, conda_rendering, fixup_building_sdist,
fixup_for_packaged, get_cmdclass, get_package_data, get_version,
install_js, package_files, package_path, ROOT, SERVER, show_bokehjs,
show_help
)
# immediately bail for ancient pythons
if sys.version_info[:2] < (2, 7):
raise RuntimeError("Bokeh requires python >= 2.7")
# immediately handle lightweight "python setup.py --install-js"
if len(sys.argv) == 2 and sys.argv[-1] == '--install-js':
install_js()
sys.exit()
# we want to have the license at the top level of the GitHub repo, but setup
# can't include it from there, so copy it to the package directory first thing
copy("LICENSE.txt", "bokeh/")
# state our runtime deps here, also used by meta.yaml (so KEEP the spaces)
REQUIRES = [
'six >=1.5.2',
'PyYAML >=3.10',
'python-dateutil >=2.1',
'Jinja2 >=2.7',
'numpy >=1.7.1',
'tornado >=4.3',
]
# handle the compat difference for futures (meta.yaml handles differently)
if sys.version_info[:2] == (2, 7):
REQUIRES.append('futures >=3.0.3')
# if this is just conda-build skimming information, skip all this actual work
if not conda_rendering():
fixup_for_packaged() # --build_js and --install_js not valid FROM sdist
fixup_building_sdist() # must build BokehJS when MAKING sdists
bokehjs_action = build_or_install_bokehjs()
# configuration to include all the special or non-python files in the package
# directory that need to also be installed or included in a build
sampledata_pats = ('.csv', '.conf', '.gz', '.json', '.png', '.ics', '.geojson')
package_path(join(SERVER, 'static'))
package_path(join(ROOT, 'bokeh', 'core', '_templates'))
package_path(join(ROOT, 'bokeh', 'sphinxext', '_templates'))
package_path(join(ROOT, 'bokeh', 'server', 'views'), ('.html'))
package_path(join(ROOT, 'bokeh', 'sampledata'), sampledata_pats)
package_files('LICENSE.txt', 'themes/*.yaml')
setup(
# basic package metadata
name='bokeh',
version=get_version(),
description='Interactive plots and applications in the browser from Python',
license='New BSD',
author='Anaconda',
author_email='[email protected]',
url='http://github.com/bokeh/bokeh',
classifiers=open("classifiers.txt").read().strip().split('\n'),
# details needed by setup
install_requires=REQUIRES,
packages=find_packages(exclude=["scripts*", "tests*"]),
package_data=get_package_data(),
entry_points={'console_scripts': ['bokeh = bokeh.__main__:main',], },
zip_safe=False,
cmdclass=get_cmdclass()
)
# if this is just conda-build skimming information, skip all this actual work
if not conda_rendering():
if '--help' in sys.argv: show_help(bokehjs_action)
if 'develop' in sys.argv: show_bokehjs(bokehjs_action, develop=True)
if 'install' in sys.argv: show_bokehjs(bokehjs_action)