setup.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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
  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. ]
  30. package_data_spec = dict()
  31. package_data_spec[NAME] = [
  32. 'staging/*', 'staging/templates/*', 'static/**', 'tests/mock_packages/**',
  33. 'themes/**', 'schemas/**'
  34. ]
  35. staging = pjoin(HERE, NAME, 'staging')
  36. npm = ['node', pjoin(staging, 'yarn.js')]
  37. VERSION = get_version('%s/_version.py' % NAME)
  38. def check_assets():
  39. from distutils.version import LooseVersion
  40. # Representative files that should exist after a successful build
  41. targets = [
  42. 'static/package.json',
  43. 'schemas/@jupyterlab/shortcuts-extension/plugin.json',
  44. 'themes/@jupyterlab/theme-light-extension/images/jupyterlab.svg'
  45. ]
  46. for t in targets:
  47. if not os.path.exists(pjoin(HERE, NAME, t)):
  48. msg = ('Missing file: %s, `build:prod` script did not complete '
  49. 'successfully' % t)
  50. raise ValueError(msg)
  51. if 'sdist' not in sys.argv and 'bdist_wheel' not in sys.argv:
  52. return
  53. target = pjoin(HERE, NAME, 'static', 'package.json')
  54. with open(target) as fid:
  55. version = json.load(fid)['jupyterlab']['version']
  56. if LooseVersion(version) != LooseVersion(VERSION):
  57. raise ValueError('Version mismatch, please run `build:update`')
  58. cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec,
  59. package_data_spec=package_data_spec)
  60. cmdclass['jsdeps'] = combine_commands(
  61. install_npm(build_cmd='build:prod', path=staging, source_dir=staging,
  62. build_dir=pjoin(HERE, NAME, 'static'), npm=npm),
  63. command_for_func(check_assets)
  64. )
  65. class JupyterlabDevelop(develop):
  66. """A custom develop command that runs yarn"""
  67. def run(self):
  68. if not skip_npm:
  69. run(npm, cwd=HERE)
  70. develop.run(self)
  71. # Use default develop - we can ensure core mode later if needed.
  72. cmdclass['develop'] = JupyterlabDevelop
  73. setup_args = dict(
  74. name = NAME,
  75. description = DESCRIPTION,
  76. long_description = LONG_DESCRIPTION,
  77. version = VERSION,
  78. packages = find_packages(),
  79. cmdclass = cmdclass,
  80. author = 'Jupyter Development Team',
  81. author_email = 'jupyter@googlegroups.com',
  82. url = 'http://jupyter.org',
  83. license = 'BSD',
  84. platforms = "Linux, Mac OS X, Windows",
  85. keywords = ['ipython', 'jupyter', 'Web'],
  86. classifiers = [
  87. 'Development Status :: 4 - Beta',
  88. 'Intended Audience :: Developers',
  89. 'Intended Audience :: System Administrators',
  90. 'Intended Audience :: Science/Research',
  91. 'License :: OSI Approved :: BSD License',
  92. 'Programming Language :: Python',
  93. 'Programming Language :: Python :: 2.7',
  94. 'Programming Language :: Python :: 3',
  95. 'Programming Language :: Python :: 3.4',
  96. 'Programming Language :: Python :: 3.5',
  97. 'Programming Language :: Python :: 3.6',
  98. ],
  99. )
  100. setup_args['install_requires'] = [
  101. 'notebook>=4.3.1',
  102. 'jupyterlab_launcher>=0.10.0,<0.11.0',
  103. 'ipython_genutils',
  104. 'futures;python_version<"3.0"',
  105. 'subprocess32;python_version<"3.0"'
  106. ]
  107. setup_args['extras_require'] = {
  108. 'test:python_version == "2.7"': ['mock'],
  109. 'test': ['pytest', 'requests', 'pytest-check-links', 'selenium'],
  110. 'docs': [
  111. 'sphinx',
  112. 'recommonmark',
  113. 'sphinx_rtd_theme'
  114. ],
  115. }
  116. setup_args['include_package_data'] = True
  117. # Force entrypoints with setuptools (needed for Windows, unconditional
  118. # because of wheels)
  119. setup_args['entry_points'] = {
  120. 'console_scripts': [
  121. 'jupyter-lab = jupyterlab.labapp:main',
  122. 'jupyter-labextension = jupyterlab.labextensions:main',
  123. 'jupyter-labhub = jupyterlab.labhubapp:main',
  124. 'jlpm = jupyterlab.jlpmapp:main',
  125. ]
  126. }
  127. if __name__ == '__main__':
  128. setup(**setup_args)