setup.py 4.5 KB

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