setupbase.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # encoding: utf-8
  2. """
  3. This module defines the things that are used in setup.py for building JupyterLab
  4. This includes:
  5. * Functions for finding things like packages, package data, etc.
  6. * A function for checking dependencies.
  7. """
  8. # Copyright (c) Jupyter Development Team.
  9. # Distributed under the terms of the Modified BSD License.
  10. import os
  11. import pipes
  12. import sys
  13. from distutils import log
  14. from setuptools.command.bdist_egg import bdist_egg
  15. from subprocess import check_call
  16. if sys.platform == 'win32':
  17. from subprocess import list2cmdline
  18. else:
  19. def list2cmdline(cmd_list):
  20. return ' '.join(map(pipes.quote, cmd_list))
  21. here = os.path.dirname(os.path.abspath(__file__))
  22. is_repo = os.path.exists(os.path.join(here, '.git'))
  23. def run(cmd, *args, **kwargs):
  24. """Echo a command before running it"""
  25. log.info('> ' + list2cmdline(cmd))
  26. kwargs['shell'] = (sys.platform == 'win32')
  27. return check_call(cmd, *args, **kwargs)
  28. #---------------------------------------------------------------------------
  29. # Find packages
  30. #---------------------------------------------------------------------------
  31. def find_packages():
  32. """
  33. Find all of the packages.
  34. """
  35. packages = []
  36. for dir, subdirs, files in os.walk('jupyterlab'):
  37. package = dir.replace(os.path.sep, '.')
  38. if '__init__.py' not in files:
  39. # not a package
  40. continue
  41. packages.append(package)
  42. return packages
  43. #---------------------------------------------------------------------------
  44. # Find package data
  45. #---------------------------------------------------------------------------
  46. def find_package_data():
  47. """
  48. Find package_data.
  49. """
  50. return {
  51. 'jupyterlab': ['static/*', 'lab.html', 'package.json', 'index.template.js', 'webpack.config.js']
  52. }
  53. class bdist_egg_disabled(bdist_egg):
  54. """Disabled version of bdist_egg
  55. Prevents setup.py install performing setuptools' default easy_install,
  56. which it should never ever do.
  57. """
  58. def run(self):
  59. sys.exit("Aborting implicit building of eggs. Use `pip install .` to install from source.")