def install_kernel_spec(self, app, dir_name, display_name,
                            settings_module, ipython_arguments):
        """install an IPython >= 3.0 kernelspec that loads corral env

        Thanks: django extensions

        """
        ksm = app.kernel_spec_manager
        try_spec_names = ['python3' if six.PY3 else 'python2', 'python']
        if isinstance(try_spec_names, six.string_types):
            try_spec_names = [try_spec_names]
        ks = None
        for spec_name in try_spec_names:
            try:
                ks = ksm.get_kernel_spec(spec_name)
                break
            except Exception:
                continue
        if not ks:
            self.parser.error("No notebook (Python) kernel specs found")

        ks.display_name = display_name
        ks.env["CORRAL_SETTINGS_MODULE"] = settings_module
        ks.argv.extend(ipython_arguments)

        in_corral_dir, in_corral = os.path.split(os.path.realpath(sys.argv[0]))

        pythonpath = ks.env.get(
            'PYTHONPATH', os.environ.get('PYTHONPATH', ''))
        pythonpath = pythonpath.split(':')
        if in_corral_dir not in pythonpath:
            pythonpath.append(in_corral_dir)
        ks.env['PYTHONPATH'] = ':'.join(filter(None, pythonpath))

        kernel_dir = os.path.join(ksm.user_kernel_dir, conf.PACKAGE)
        if not os.path.exists(kernel_dir):
            os.makedirs(kernel_dir)
            shutil.copy(res.fullpath("logo-64x64.png"), kernel_dir)
        with open(os.path.join(kernel_dir, 'kernel.json'), 'w') as f:
            f.write(ks.to_json())
install an IPython >= 3.0 kernelspec that loads corral env

        Thanks: django extensions