setup.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. # Copyright (c) Jupyter Development Team.
  4. # Distributed under the terms of the Modified BSD License.
  5. from os.path import join as pjoin
  6. import json
  7. import os
  8. import sys
  9. # Our own imports
  10. from setupbase import (
  11. create_cmdclass, ensure_python, find_packages, get_version,
  12. command_for_func, combine_commands, install_npm, HERE, run,
  13. skip_npm, which, log
  14. )
  15. from setuptools import setup
  16. from setuptools.command.develop import develop
  17. NAME = 'jupyterlab'
  18. DESCRIPTION = 'The JupyterLab notebook server extension.'
  19. LONG_DESCRIPTION = """
  20. This is a beta release of JupyterLab.
  21. Development happens on https://github.com/jupyter/jupyterlab, with chat on
  22. https://gitter.im/jupyter/jupyterlab.
  23. """
  24. ensure_python(['2.7', '>=3.3'])
  25. data_files_spec = [
  26. ('share/jupyter/lab/static', '%s/static' % NAME, '**'),
  27. ('share/jupyter/lab/schemas', '%s/schemas' % NAME, '**'),
  28. ('share/jupyter/lab/themes', '%s/themes' % NAME, '**'),
  29. ('etc/jupyter/jupyter_notebook_config.d',
  30. 'jupyter-config/jupyter_notebook_config.d', 'jupyterlab.json'),
  31. ]
  32. package_data_spec = dict()
  33. package_data_spec[NAME] = [
  34. 'staging/*', 'staging/templates/*', 'static/**', 'tests/mock_packages/**',
  35. 'themes/**', 'schemas/**', 'node-version-check.js'
  36. ]
  37. staging = pjoin(HERE, NAME, 'staging')
  38. npm = ['node', pjoin(staging, 'yarn.js')]
  39. VERSION = get_version('%s/_version.py' % NAME)
  40. def check_assets():
  41. from distutils.version import LooseVersion
  42. # Representative files that should exist after a successful build
  43. targets = [
  44. 'static/package.json',
  45. 'schemas/@jupyterlab/shortcuts-extension/plugin.json',
  46. 'themes/@jupyterlab/theme-light-extension/index.css'
  47. ]
  48. for t in targets:
  49. if not os.path.exists(pjoin(HERE, NAME, t)):
  50. msg = ('Missing file: %s, `build:prod` script did not complete '
  51. 'successfully' % t)
  52. raise ValueError(msg)
  53. if 'sdist' not in sys.argv and 'bdist_wheel' not in sys.argv:
  54. return
  55. target = pjoin(HERE, NAME, 'static', 'package.json')
  56. with open(target) as fid:
  57. version = json.load(fid)['jupyterlab']['version']
  58. if LooseVersion(version) != LooseVersion(VERSION):
  59. raise ValueError('Version mismatch, please run `build:update`')
  60. cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec,
  61. package_data_spec=package_data_spec)
  62. cmdclass['jsdeps'] = combine_commands(
  63. install_npm(build_cmd='build:prod', path=staging, source_dir=staging,
  64. build_dir=pjoin(HERE, NAME, 'static'), npm=npm),
  65. command_for_func(check_assets)
  66. )
  67. class JupyterlabDevelop(develop):
  68. """A custom develop command that runs yarn"""
  69. def run(self):
  70. if not skip_npm:
  71. if not which('node'):
  72. log.error('Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.')
  73. return
  74. run(npm, cwd=HERE)
  75. develop.run(self)
  76. # Use default develop - we can ensure core mode later if needed.
  77. cmdclass['develop'] = JupyterlabDevelop
  78. setup_args = dict(
  79. name = NAME,
  80. description = DESCRIPTION,
  81. long_description = LONG_DESCRIPTION,
  82. version = VERSION,
  83. packages = find_packages(),
  84. cmdclass = cmdclass,
  85. author = 'Jupyter Development Team',
  86. author_email = 'jupyter@googlegroups.com',
  87. url = 'http://jupyter.org',
  88. license = 'BSD',
  89. platforms = "Linux, Mac OS X, Windows",
  90. keywords = ['ipython', 'jupyter', 'Web'],
  91. classifiers = [
  92. 'Development Status :: 4 - Beta',
  93. 'Intended Audience :: Developers',
  94. 'Intended Audience :: System Administrators',
  95. 'Intended Audience :: Science/Research',
  96. 'License :: OSI Approved :: BSD License',
  97. 'Programming Language :: Python',
  98. 'Programming Language :: Python :: 2.7',
  99. 'Programming Language :: Python :: 3',
  100. 'Programming Language :: Python :: 3.4',
  101. 'Programming Language :: Python :: 3.5',
  102. 'Programming Language :: Python :: 3.6',
  103. ],
  104. )
  105. setup_args['install_requires'] = [
  106. 'notebook>=4.3.1',
  107. 'jupyterlab_launcher>=0.11.0,<0.12.0',
  108. 'ipython_genutils',
  109. 'futures;python_version<"3.0"',
  110. 'subprocess32;python_version<"3.0"'
  111. ]
  112. setup_args['extras_require'] = {
  113. 'test:python_version == "2.7"': ['mock'],
  114. 'test': ['pytest', 'requests', 'pytest-check-links', 'selenium'],
  115. 'docs': [
  116. 'sphinx',
  117. 'recommonmark',
  118. 'sphinx_rtd_theme'
  119. ],
  120. }
  121. setup_args['include_package_data'] = True
  122. # Force entrypoints with setuptools (needed for Windows, unconditional
  123. # because of wheels)
  124. setup_args['entry_points'] = {
  125. 'console_scripts': [
  126. 'jupyter-lab = jupyterlab.labapp:main',
  127. 'jupyter-labextension = jupyterlab.labextensions:main',
  128. 'jupyter-labhub = jupyterlab.labhubapp:main',
  129. 'jlpm = jupyterlab.jlpmapp:main',
  130. ]
  131. }
  132. if __name__ == '__main__':
  133. setup(**setup_args)