setup.py 4.5 KB

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