123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- from distutils.core import setup
- from distutils.command.install import install
- from distutils import log
- import json
- import os
- import sys
- kernel_json = { 'argv': ['python', '-m' ,'jupyter-mysql-kernel',
- '-f', '{connection_file}'],
- 'display_name': 'Mysql',
- 'language': 'mysql',
- }
- class install_with_kernelspec(install):
- def run(self):
-
- install.run(self)
-
- from IPython.kernel.kernelspec import install_kernel_spec
- from IPython.utils.tempdir import TemporaryDirectory
- with TemporaryDirectory() as td:
- os.chmod(td, 0o755)
- with open(os.path.join(td, 'kernel.json'), 'w') as f:
- json.dump(kernel_json, f, sort_keys=True)
-
- log.info('Installing IPython kernel spec')
- install_kernel_spec(td, 'jupyter-mysql-kernel', user=self.user, replace=True)
- with open('README.md','r') as f:
- readme = f.read()
- svem_flag = '--single-version-externally-managed'
- if svem_flag in sys.argv:
- sys.argv.remove(svem_flag)
- setup(name='jupyter-mysql-kernel',
- version='0.0.1',
- description='A mysql kernel for Jupyter',
- long_description=readme,
- author='rabin',
- author_email='2934170@gmail.com',
- url='https://github.com/shemic/jupyter-mysql-kernel',
- packages=['jupyter-mysql-kernel'],
- cmdclass={'install': install_with_kernelspec},
- install_requires=['pymysql','prettytable'],
- classifiers = [
- 'Framework :: IPython',
- 'License :: OSI Approved :: BSD License',
- 'Programming Language :: Python :: 3',
- 'Topic :: System :: Shells',
- ]
- )
|