1
#!/usr/bin/env python
2

3 0
import os
4 0
import shutil
5 0
import sys
6 0
import json
7

8 0
from setuptools import setup, find_packages
9 0
from setuptools.command.develop import develop
10 0
from setuptools.command.install import install
11 0
from setuptools.command.sdist import sdist
12

13 0
import pyct.build
14

15

16 0
def get_setup_version(reponame):
17
    """
18
    Helper to get the current version from either git describe or the
19
    .version file (if available).
20
    """
21 0
    basepath = os.path.split(__file__)[0]
22 0
    version_file_path = os.path.join(basepath, reponame, '.version')
23 0
    try:
24 0
        from param import version
25 0
    except Exception:
26 0
        version = None
27 0
    if version is not None:
28 0
        return version.Version.setup_version(basepath, reponame, archive_commit="$Format:%h$")
29
    else:
30 0
        print("WARNING: param>=1.6.0 unavailable. If you are installing a package, "
31
              "this warning can safely be ignored. If you are creating a package or "
32
              "otherwise operating in a git repository, you should install param>=1.6.0.")
33 0
        return json.load(open(version_file_path, 'r'))['version_string']
34

35

36 0
def _build_paneljs():
37 0
    from bokeh.ext import build
38 0
    print("Building custom models:")
39 0
    panel_dir = os.path.join(os.path.dirname(__file__), "panel")
40 0
    build(panel_dir)
41

42

43 0
class CustomDevelopCommand(develop):
44
    """Custom installation for development mode."""
45

46 0
    def run(self):
47 0
        _build_paneljs()
48 0
        develop.run(self)
49

50

51 0
class CustomInstallCommand(install):
52
    """Custom installation for install mode."""
53

54 0
    def run(self):
55 0
        _build_paneljs()
56 0
        install.run(self)
57

58

59 0
class CustomSdistCommand(sdist):
60
    """Custom installation for sdist mode."""
61

62 0
    def run(self):
63 0
        _build_paneljs()
64 0
        sdist.run(self)
65

66

67 0
_COMMANDS = {
68
    'develop': CustomDevelopCommand,
69
    'install': CustomInstallCommand,
70
    'sdist':   CustomSdistCommand,
71
}
72

73 0
try:
74 0
    from wheel.bdist_wheel import bdist_wheel
75

76 0
    class CustomBdistWheelCommand(bdist_wheel):
77
        """Custom bdist_wheel command to force cancelling qiskit-terra wheel
78
        creation."""
79

80 0
        def run(self):
81
            """Do nothing so the command intentionally fails."""
82 0
            _build_paneljs()
83 0
            bdist_wheel.run(self)
84

85 0
    _COMMANDS['bdist_wheel'] = CustomBdistWheelCommand
86 0
except Exception:
87 0
    pass
88

89
########## dependencies ##########
90

91 0
install_requires = [
92
    'bokeh >=2.1',
93
    'param >=1.9.3',
94
    'pyviz_comms >=0.7.4',
95
    'markdown',
96
    'tqdm',
97
    'pyct >=0.4.4'
98
]
99

100 0
_recommended = [
101
    'notebook >=5.4',
102
    'holoviews >=1.13.2',
103
    'matplotlib',
104
    'pillow',
105
    'plotly'
106
]
107

108 0
_tests = [
109
    'flake8',
110
    'parameterized',
111
    'pytest<6.0', # temporary fix for nbval incompatibility
112
    'scipy',
113
    'nbsmoke >=0.2.0',
114
    'pytest-cov',
115
    'codecov',
116
    'folium',
117
    'ipympl',
118
    'pandas<1.1' # temporary fix for streamz incompatibility
119
]
120

121 0
extras_require = {
122
    'examples': [
123
        'hvplot',
124
        'plotly',
125
        'altair',
126
        'streamz',
127
        'vega_datasets',
128
        'vtk',
129
        'scikit-learn',
130
        'datashader',
131
        'jupyter_bokeh',
132
        'django',
133
        'pyvista',
134
        'ipywidgets',
135
        'ipywidgets_bokeh',
136
        'ipyvolume',
137
        'ipyleaflet'
138
    ],
139
    'tests': _tests,
140
    'recommended': _recommended,
141
    'doc': _recommended + [
142
        'nbsite >=0.6.1',
143
        'sphinx_holoviz_theme',
144
        'selenium',
145
        'phantomjs',
146
        'graphviz',
147
        'lxml',
148
    ]
149
}
150

151 0
extras_require['all'] = sorted(set(sum(extras_require.values(), [])))
152

153
# Superset of what's in pyproject.toml (includes non-python
154
# dependencies).  Also, pyproject.toml isn't supported by all tools
155
# anyway (e.g. older versions of pip, or conda - which also supports
156
# non-python dependencies). Note that setup_requires isn't used
157
# because it doesn't work well with pip.
158 0
extras_require['build'] = [
159
    'param >=1.9.2',
160
    'pyct >=0.4.4',
161
    'setuptools >=30.3.0',
162
    'bokeh >=2.0.0',
163
    'pyviz_comms >=0.6.0',
164
    # non-python dependency
165
    'nodejs >=9.11.1',
166
]
167

168 0
setup_args = dict(
169
    name='panel',
170
    version=get_setup_version("panel"),
171
    description='A high level app and dashboarding solution for Python.',
172
    long_description=open('README.md').read() if os.path.isfile('README.md') else 'Consult README.md',
173
    long_description_content_type="text/markdown",
174
    author="HoloViz",
175
    author_email="developers@holoviz.org",
176
    maintainer="HoloViz",
177
    maintainer_email="developers@holoviz.org",
178
    platforms=['Windows', 'Mac OS X', 'Linux'],
179
    license='BSD',
180
    url='http://panel.holoviz.org',
181
    cmdclass=_COMMANDS,
182
    packages=find_packages(),
183
    include_package_data=True,
184
    classifiers=[
185
        "License :: OSI Approved :: BSD License",
186
        "Development Status :: 5 - Production/Stable",
187
        "Programming Language :: Python :: 3",
188
        "Programming Language :: Python :: 3.6",
189
        "Programming Language :: Python :: 3.7",
190
        "Programming Language :: Python :: 3.8",
191
        "Operating System :: OS Independent",
192
        "Intended Audience :: Developers",
193
        "Intended Audience :: Science/Research",
194
        "Intended Audience :: Financial and Insurance Industry",
195
        "Intended Audience :: Healthcare Industry",
196
        "Intended Audience :: Information Technology",
197
        "Intended Audience :: Legal Industry",
198
        "Intended Audience :: Other Audience",
199
        "Intended Audience :: Science/Research",
200
        "Natural Language :: English",
201
        "Topic :: Scientific/Engineering",
202
        "Topic :: Scientific/Engineering :: Visualization",
203
        "Topic :: Scientific/Engineering :: Information Analysis",
204
        "Topic :: Office/Business",
205
        "Topic :: Office/Business :: Financial",
206
        "Topic :: Software Development :: Libraries"],
207
    python_requires=">=3.6",
208
    entry_points={
209
        'console_scripts': [
210
            'panel = panel.command:main'
211
        ]},
212
    install_requires=install_requires,
213
    extras_require=extras_require,
214
    tests_require=extras_require['tests']
215
)
216

217 0
if __name__ == "__main__":
218 0
    example_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
219
                                'panel', 'examples')
220

221 0
    if 'develop' not in sys.argv and 'egg_info' not in sys.argv:
222 0
        pyct.build.examples(example_path, __file__, force=True)
223

224 0
    version = setup_args['version']
225 0
    if 'post' not in version:
226 0
        with open('./panel/package.json') as f:
227 0
            package_json = json.load(f)
228 0
        js_version = package_json['version']
229 0
        if version.split('+')[0] != js_version.replace('-', ''):
230 0
            raise ValueError("panel.js version (%s) does not match "
231
                             "panel version (%s). Cannot build release."
232
                             % (js_version, version))
233

234 0
    setup(**setup_args)
235

236 0
    if os.path.isdir(example_path):
237 0
        shutil.rmtree(example_path)

Read our documentation on viewing source code .

Loading