setup.py 4.4 KB

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