-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
106 lines (83 loc) · 3.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
import sys
import subprocess
from distutils import log
from setuptools import setup
from setuptools.command.install import install
# General Requirements
SETUP_REQUIRES = ['ipython', 'ipykernel']
INSTALL_REQUIRES = ['mathics>=1.0.dev0'] + SETUP_REQUIRES
kernel_json = {
'argv': [sys.executable,
'-m', 'imathics',
'-f', '{connection_file}'],
'display_name': 'mathics',
'language': 'Mathematica',
'name': 'mathics',
}
class InstallIMathics(install):
def run(self):
# The recommended way is with the setup_requires argument to setup
# This fails because ipython doesn't build under easy_install
subprocess.check_call([sys.executable, '-m', 'pip', 'install'] + SETUP_REQUIRES)
# Unfortunately the recommended call to 'install.run(self)'
# will completely ignore the install_requirements.
# So we trick it by calling the underlying bdist_egg instead:
self.do_egg_install()
self.install_kernelspec()
def install_kernelspec(self):
from ipykernel.kernelspec import write_kernel_spec
from jupyter_client.kernelspec import KernelSpecManager
kernel_spec_manager = KernelSpecManager()
log.info('Writing kernel spec')
kernel_spec_path = write_kernel_spec(overrides=kernel_json)
log.info('Installing kernel spec ' + kernel_spec_path)
try:
kernel_spec_manager.install_kernel_spec(
kernel_spec_path,
kernel_name=kernel_json['name'],
user=self.user)
except Exception as e:
log.error(str(e.args))
log.error('Failed to install kernel spec')
else:
return
# retry with not self.user
log.info('Retry install kernel spec')
try:
kernel_spec_manager.install_kernel_spec(
kernel_spec_path,
kernel_name=kernel_json['name'],
user=not self.user)
except Exception as e:
log.error(str(e.args))
log.error('Failed to install kernel spec')
setup(
name="imathics",
cmdclass={'install': InstallIMathics},
version='0.1',
packages=['imathics'],
install_requires=INSTALL_REQUIRES,
entry_points={
'console_scripts': [
'imathics = imathics.terminalapp:main',
],
},
# metadata for upload to PyPI
author="Angus Griffith",
author_email="[email protected]",
description="A jupyter kernel for mathics",
url="http://www.mathics.github.io/",
keywords=['Mathematica', 'Wolfram', 'Interpreter', 'Shell', 'Math', 'CAS'],
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2 :: Only',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
],
)