Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/src/sage_setup/command/sage_install.py
4081 views
1
#########################################################
2
### Install Jupyter kernel spec
3
#########################################################
4
5
import os
6
import time
7
8
# Import setuptools before importing distutils, so that setuptools
9
# can replace distutils by its own vendored copy.
10
import setuptools
11
12
from distutils import log
13
from distutils.command.install import install
14
from setuptools.command.develop import develop
15
16
17
class install_kernel_spec_mixin:
18
19
def install_kernel_spec(self):
20
"""
21
Install the Jupyter kernel spec.
22
23
.. NOTE::
24
25
The files are generated, not copied. Therefore, we cannot
26
use ``data_files`` for this.
27
"""
28
from sage.repl.ipython_kernel.install import SageKernelSpec
29
# Jupyter packages typically use the data_files option to
30
# setup() to install kernels and nbextensions. So we should use
31
# the install_data directory for installing our Jupyter files.
32
SageKernelSpec.update(prefix=self.install_data)
33
34
35
class sage_install(install, install_kernel_spec_mixin):
36
37
def run(self):
38
install.run(self)
39
self.install_kernel_spec()
40
41
42
class sage_develop(develop, install_kernel_spec_mixin):
43
44
def run(self):
45
develop.run(self)
46
if not self.uninstall:
47
self.install_kernel_spec()
48
49