├── .gitignore ├── MANIFEST.in ├── Makefile ├── README.md ├── setup.py └── skulpt_python ├── __init__.py ├── __main__.py ├── images ├── logo-32x32.png └── logo-64x64.png └── kernel.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | MANIFEST 60 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include setup.py 2 | include README.md 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | python setup.py register 3 | python setup.py sdist --formats=gztar,zip upload 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Skulpt Python Kernel** is the merging of [Skulpt](http://www.skulpt.org/) (a Python implementation that runs in the browser) with [Project Jupyter](http://jupyter.org/) (aka IPython). In addtion, it has an interface to [ProcessingJS](http://processingjs.org/). Skulpt scripts are entered into a cell, where they run independently from other cells. 2 | 3 | Because Skulpt Kernel uses [MetaKernel](https://github.com/Calysto/metakernel/blob/master/README.rst), it has a fully-supported set of "magics"---meta-commands for additional functionality. A list of magics can be seen at [MetaKernel Magics](https://github.com/Calysto/metakernel/blob/master/metakernel/magics/README.md). 4 | 5 | Skulpt Kernel in use: 6 | 7 | * [Video](https://www.youtube.com/watch?v=iSGXOU5C3sQ) 8 | * [Example notebook from video](http://jupyter.cs.brynmawr.edu/hub/dblank/public/Examples/Skulpt%20Python%20Examples.ipynb) 9 | 10 | You can install Skulpt Kernel with: 11 | 12 | ``` 13 | pip install --upgrade skulpt_python 14 | ``` 15 | 16 | or in the system kernels with: 17 | 18 | ``` 19 | sudo pip install --upgrade skulpt_python 20 | ``` 21 | 22 | Use it in the notebook with: 23 | 24 | ``` 25 | ipython notebook 26 | ``` 27 | 28 | and select `Skulpt Python` as the kernel for a new notebook. 29 | 30 | Requires: 31 | 32 | * ipython-3.0+ 33 | * Python2 or Python3 34 | * metakernel (installed with pip) 35 | * calysto (installed with pip) 36 | 37 | Skulpt Kernel supports: 38 | 39 | * MetaKernel Magics 40 | * processing 41 | * turtle 42 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from distutils.command.install import install 2 | from distutils.core import setup 3 | from distutils import log 4 | import os 5 | import json 6 | import sys 7 | 8 | kernel_json = { 9 | "argv": [sys.executable, 10 | "-m", "skulpt_python", 11 | "-f", "{connection_file}"], 12 | "display_name": "Skulpt Python", 13 | "language": "python", 14 | "name": "skulpt_python" 15 | } 16 | 17 | class install_with_kernelspec(install): 18 | def run(self): 19 | install.run(self) 20 | from IPython.kernel.kernelspec import install_kernel_spec 21 | from IPython.utils.tempdir import TemporaryDirectory 22 | from metakernel.utils.kernel import install_kernel_resources 23 | with TemporaryDirectory() as td: 24 | os.chmod(td, 0o755) # Starts off as 700, not user readable 25 | with open(os.path.join(td, 'kernel.json'), 'w') as f: 26 | json.dump(kernel_json, f, sort_keys=True) 27 | install_kernel_resources(td, resource="skulpt_python") 28 | log.info('Installing kernel spec') 29 | try: 30 | install_kernel_spec(td, 'skulpt_python', user=self.user, 31 | replace=True) 32 | except: 33 | install_kernel_spec(td, 'skulpt_python', user=not self.user, 34 | replace=True) 35 | 36 | 37 | svem_flag = '--single-version-externally-managed' 38 | if svem_flag in sys.argv: 39 | # Die, setuptools, die. 40 | sys.argv.remove(svem_flag) 41 | 42 | with open('skulpt_python/__init__.py', 'rb') as fid: 43 | for line in fid: 44 | line = line.decode('utf-8') 45 | if line.startswith('__version__'): 46 | __version__ = line.strip().split()[-1][1:-1] 47 | break 48 | 49 | with open('README.md') as f: 50 | readme = f.read() 51 | 52 | setup(name='skulpt_python', 53 | version=__version__, 54 | description='A Skulpt Python kernel in the browser for Jupyter', 55 | long_description=readme, 56 | url="https://github.com/Calysto/skulpt_python", 57 | author='Douglas Blank', 58 | author_email='doug.blank@gmail.com', 59 | packages=["skulpt_python"], 60 | install_requires=["metakernel"], 61 | cmdclass={'install': install_with_kernelspec}, 62 | classifiers = [ 63 | 'Framework :: IPython', 64 | 'License :: OSI Approved :: BSD License', 65 | 'Programming Language :: Python :: 3', 66 | 'Programming Language :: Python :: 2', 67 | 'Topic :: System :: Shells', 68 | ] 69 | ) 70 | -------------------------------------------------------------------------------- /skulpt_python/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.9.3' 2 | -------------------------------------------------------------------------------- /skulpt_python/__main__.py: -------------------------------------------------------------------------------- 1 | from IPython.kernel.zmq.kernelapp import IPKernelApp 2 | from .kernel import SkulptPythonKernel 3 | IPKernelApp.launch_instance(kernel_class=SkulptPythonKernel) 4 | -------------------------------------------------------------------------------- /skulpt_python/images/logo-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Calysto/skulpt_python/f2e18ec49b70193904bcf7d796f7699c5128a22e/skulpt_python/images/logo-32x32.png -------------------------------------------------------------------------------- /skulpt_python/images/logo-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Calysto/skulpt_python/f2e18ec49b70193904bcf7d796f7699c5128a22e/skulpt_python/images/logo-64x64.png -------------------------------------------------------------------------------- /skulpt_python/kernel.py: -------------------------------------------------------------------------------- 1 | from metakernel import MetaKernel 2 | from IPython.display import HTML, Javascript 3 | import sys 4 | import re 5 | 6 | class SkulptPythonKernel(MetaKernel): 7 | implementation = 'Skulpt Python' 8 | implementation_version = '1.0' 9 | language = 'python' 10 | language_version = '0.1' 11 | language_info = { 12 | 'mimetype': 'text/x-python', 13 | 'name': 'python', 14 | 'codemirror_mode': { 15 | "version": 2, 16 | "name": "text/x-python" 17 | }, 18 | # 'pygments_lexer': 'language', 19 | # 'version' : "x.y.z", 20 | 'file_extension': '.py', 21 | } 22 | banner = "Skulpt Python kernel - evaluates Python programs in the browser" 23 | canvas_id = 0 24 | keywords = [] 25 | 26 | def get_usage(self): 27 | return "This is a Skulpt Python kernel" 28 | 29 | def do_execute_direct(self, code): 30 | """%%processing - run contents of cell as a Skulpt Python script""" 31 | if code.strip() == "": 32 | return 33 | self.canvas_id += 1 34 | 35 | env = {"code": repr(code)[1:] if sys.version.startswith('2') else repr(code), 36 | "id": self.canvas_id} 37 | code = """ 38 |