-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
69 lines (62 loc) · 2.29 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from distutils.command.install import install
from distutils.core import setup
from distutils import log
import os
import json
import sys
kernel_json = {
"argv": [sys.executable,
"-m", "skulpt_python",
"-f", "{connection_file}"],
"display_name": "Skulpt Python",
"language": "python",
"name": "skulpt_python"
}
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
from metakernel.utils.kernel import install_kernel_resources
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
install_kernel_resources(td, resource="skulpt_python")
log.info('Installing kernel spec')
try:
install_kernel_spec(td, 'skulpt_python', user=self.user,
replace=True)
except:
install_kernel_spec(td, 'skulpt_python', user=not self.user,
replace=True)
svem_flag = '--single-version-externally-managed'
if svem_flag in sys.argv:
# Die, setuptools, die.
sys.argv.remove(svem_flag)
with open('skulpt_python/__init__.py', 'rb') as fid:
for line in fid:
line = line.decode('utf-8')
if line.startswith('__version__'):
__version__ = line.strip().split()[-1][1:-1]
break
with open('README.md') as f:
readme = f.read()
setup(name='skulpt_python',
version=__version__,
description='A Skulpt Python kernel in the browser for Jupyter',
long_description=readme,
url="https://github.com/Calysto/skulpt_python",
author='Douglas Blank',
author_email='[email protected]',
packages=["skulpt_python"],
install_requires=["metakernel"],
cmdclass={'install': install_with_kernelspec},
classifiers = [
'Framework :: IPython',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 2',
'Topic :: System :: Shells',
]
)