IPython kernels for teaching and learning C/C++ in a Jupyter notebook, providing C/C++ syntax highlighting and a little more magic.
Project description
c-kernel
IPython kernels for teaching and learning C/C++ in a Jupyter notebook, providing C/C++ syntax highlighting, automatic compilation and a little more magic.
AutoCompileKernel
Automatically compile cells into object files or executables using the name given on the cell's first line:
Specify options in comments using //%:
Compose simple multi-file projects in a single notebook:
Interactive text input between notebook and the compiled executable:
Available options
The following options can be specified in a //% magic comment within a code cell:
| Option | Meaning | Example |
|---|---|---|
CC |
set the C compiler | CC clang |
CXX |
set the C++ compiler | CXX clang++ |
CFLAGS |
add C compilation flags | CFLAGS -Wall |
CXXFLAGS |
add C++ compilation flags | CXXFLAGS -std=c++17 |
LDFLAGS |
add linker flags | LDFLAGS -lm |
DEPENDS |
add .o dependencies, separated by spaces | DEPENDS mycode.o |
VERBOSE |
extra output from the kernel | |
ARGS |
command-line arguments to the executable | ARGS arg1 arg2 etc |
NOCOMPILE |
save and don't compile the code cell | |
NOEXEC |
save and compile, but don't execute the code cell |
Installation
To install with pip:
python3 -m pip install ckernel
To install from git:
git clone git@github.com:adamtuft/c-kernel.git
python3 -m pip install ./c-kernel
Then, install the kernel(s), giving it a name and a display name of your choice.
For example, to install AutoCompileKernel using clang and clang++ as the
default compilers, run:
ckernel install AutoCompileKernel autocompile-clang "Auto-compile C/C++ (clang)" --user --cc clang --cxx clang++
This kernel will then be available under the name "Auto-compile C/C++ (clang)" in Jupyter:
Here are some commands for installing the kernel for use with clang and gcc, with both regular and debug versions:
python3 -m ckernel install AutoCompileKernel autocompile-gcc "Auto-compile C/C++ (gcc)" --user --cc gcc --cxx g++
python3 -m ckernel install AutoCompileKernel autocompile-gcc-debug "Auto-compile C/C++ (gcc) (debug)" --user --debug --cc gcc --cxx g++
python3 -m ckernel install AutoCompileKernel autocompile-clang "Auto-compile C/C++ (clang)" --user --cc clang --cxx clang++
python3 -m ckernel install AutoCompileKernel autocompile-clang-debug "Auto-compile C/C++ (clang) (debug)" --user --debug --cc clang --cxx clang++
jupyter kernelspec list
See ckernel install --help for all options.
Issues
Please report any issues on GitHub.
License
Licensed under the BSD 3-Clause License (see the license file).
Copyright (c) 2023, Adam Tuft
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckernel-0.3.0.tar.gz.
File metadata
- Download URL: ckernel-0.3.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
def6d69556e4f1038b9df640e5ac57cb7908df21ed86644b0fb6569c9120e90b
|
|
| MD5 |
13ee931ee66941a2efccbe908856ed55
|
|
| BLAKE2b-256 |
39ff70981db7e2431156728f5ec9fa4a85234e4525d2b74375c6b7352591e201
|
File details
Details for the file ckernel-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ckernel-0.3.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e927d4d4bb5a330a7b055bef04a2c9226f9486df02e6f038c2498affce274005
|
|
| MD5 |
c4908da4b22f9a03dab86d1b52b20898
|
|
| BLAKE2b-256 |
7229e184d6e3ea24249d635ee806725c8d7e0af1515db6cd5e1465074f25e68a
|