setup.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from distutils.core import setup
  2. from distutils.command.install import install
  3. from distutils import log
  4. import json
  5. import os
  6. import sys
  7. kernel_json = { 'argv': ['python', '-m' ,'jupyter-mysql-kernel',
  8. '-f', '{connection_file}'],
  9. 'display_name': 'Mysql',
  10. 'language': 'mysql',
  11. }
  12. # this code from bash_kernel made by Thomas Kluyver
  13. # (https://github.com/takluyver/bash_kernel)
  14. class install_with_kernelspec(install):
  15. def run(self):
  16. # Regular installation
  17. install.run(self)
  18. # Now write the kernelspec
  19. from IPython.kernel.kernelspec import install_kernel_spec
  20. from IPython.utils.tempdir import TemporaryDirectory
  21. with TemporaryDirectory() as td:
  22. os.chmod(td, 0o755) # Starts off as 700, not user readable
  23. with open(os.path.join(td, 'kernel.json'), 'w') as f:
  24. json.dump(kernel_json, f, sort_keys=True)
  25. # TODO: Copy resources once they're specified
  26. log.info('Installing IPython kernel spec')
  27. install_kernel_spec(td, 'jupyter-mysql-kernel', user=self.user, replace=True)
  28. with open('README.md','r') as f:
  29. readme = f.read()
  30. svem_flag = '--single-version-externally-managed'
  31. if svem_flag in sys.argv:
  32. sys.argv.remove(svem_flag)
  33. setup(name='jupyter-mysql-kernel',
  34. version='0.0.1',
  35. description='A mysql kernel for Jupyter',
  36. long_description=readme,
  37. author='rabin',
  38. author_email='2934170@gmail.com',
  39. url='https://github.com/shemic/jupyter-mysql-kernel',
  40. packages=['jupyter-mysql-kernel'],
  41. cmdclass={'install': install_with_kernelspec},
  42. install_requires=['pymysql','prettytable'],
  43. classifiers = [
  44. 'Framework :: IPython',
  45. 'License :: OSI Approved :: BSD License',
  46. 'Programming Language :: Python :: 3',
  47. 'Topic :: System :: Shells',
  48. ]
  49. )