setup.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 = 'An alpha preview of the JupyterLab notebook server extension.'
  19. LONG_DESCRIPTION = """
  20. This is an alpha preview of JupyterLab. It is not ready for general usage yet.
  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. if 'develop' in sys.argv:
  47. if skip_npm:
  48. return
  49. run(npm, cwd=HERE)
  50. for t in targets:
  51. if not os.path.exists(pjoin(HERE, NAME, t)):
  52. msg = ('Missing file: %s, `build:prod` script did not complete '
  53. 'successfully' % t)
  54. raise ValueError(msg)
  55. if 'sdist' not in sys.argv and 'bdist_wheel' not in sys.argv:
  56. return
  57. target = pjoin(HERE, NAME, 'static', 'package.json')
  58. with open(target) as fid:
  59. version = json.load(fid)['jupyterlab']['version']
  60. if LooseVersion(version) != LooseVersion(VERSION):
  61. raise ValueError('Version mismatch, please run `build:update`')
  62. cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec,
  63. package_data_spec=package_data_spec)
  64. cmdclass['jsdeps'] = combine_commands(
  65. install_npm(build_cmd='build:prod', path=staging, source_dir=staging,
  66. build_dir=pjoin(HERE, NAME, 'static'), npm=npm),
  67. command_for_func(check_assets)
  68. )
  69. # Use default develop - we can ensure core mode later if needed.
  70. cmdclass['develop'] = develop
  71. setup_args = dict(
  72. name = NAME,
  73. description = DESCRIPTION,
  74. long_description = LONG_DESCRIPTION,
  75. version = VERSION,
  76. packages = find_packages(),
  77. cmdclass = cmdclass,
  78. author = 'Jupyter Development Team',
  79. author_email = 'jupyter@googlegroups.com',
  80. url = 'http://jupyter.org',
  81. license = 'BSD',
  82. platforms = "Linux, Mac OS X, Windows",
  83. keywords = ['ipython', 'jupyter', 'Web'],
  84. classifiers = [
  85. 'Development Status :: 3 - Alpha',
  86. 'Intended Audience :: Developers',
  87. 'Intended Audience :: System Administrators',
  88. 'Intended Audience :: Science/Research',
  89. 'License :: OSI Approved :: BSD License',
  90. 'Programming Language :: Python',
  91. 'Programming Language :: Python :: 2.7',
  92. 'Programming Language :: Python :: 3',
  93. 'Programming Language :: Python :: 3.4',
  94. 'Programming Language :: Python :: 3.5',
  95. 'Programming Language :: Python :: 3.6',
  96. ],
  97. )
  98. setup_args['install_requires'] = [
  99. 'notebook>=4.3.1',
  100. 'jupyterlab_launcher>=0.8.0,<0.9.0',
  101. 'ipython_genutils',
  102. 'futures;python_version<"3.0"',
  103. 'subprocess32;python_version<"3.0"'
  104. ]
  105. setup_args['extras_require'] = {
  106. 'test:python_version == "2.7"': ['mock'],
  107. 'test': ['pytest', 'requests', 'pytest-check-links', 'selenium'],
  108. 'docs': [
  109. 'sphinx',
  110. 'recommonmark',
  111. 'sphinx_rtd_theme'
  112. ],
  113. }
  114. setup_args['include_package_data'] = True
  115. # Force entrypoints with setuptools (needed for Windows, unconditional
  116. # because of wheels)
  117. setup_args['entry_points'] = {
  118. 'console_scripts': [
  119. 'jupyter-lab = jupyterlab.labapp:main',
  120. 'jupyter-labextension = jupyterlab.labextensions:main',
  121. 'jupyter-labhub = jupyterlab.labhubapp:main',
  122. 'jlpm = jupyterlab.jlpmapp:main',
  123. ]
  124. }
  125. if __name__ == '__main__':
  126. setup(**setup_args)