Jupyter Notebook widget for creating and exporting quantum circuits using the QuCAT Circuit generator. Built with AnyWidget and esbuild.
You can install jcircuit with pip:
pip install jcircuit
Open a Jupyter Notebook and run:
from jcircuit import JCircuitWidget
my_widget = JCircuitWidget()
my_widget
Once you have created your QuCAT circuit, you can click on the Export circuit
button. Only then can you view the netlist elements in the Jupyter Notebook with:
my_widget.circuitElements
See example.ipynb
.
This Python Jupyter Notebook widget is built with AnyWidget
and uses esbuild
to bundle the JavaScript code.
You can change the QuCAT Circuit Generator version in the dependencies
section of package.json
. This file defines the npm dependencies and the build scripts needed for the JavaScript code.
The JavaScript code is in src/widget.js
. This has to be kept in sync with gui-circuit-generator/src/gui/main.js
and just enough of gui-circuit-generator/src/gui/gui.html
, converted to JavaScript.
The JavaScript build process creates a jcircuit/static
directory with the bundled JavaScript code and other static files needed for the widget.
You can change the (Test)PyPI version number in pyproject.toml
. This file defines the Python package metadata and dependencies.
The Python code is in jcircuit/__init__.py
.
The environment.yml
file defines the conda environment with the necessary dependencies for development.
The Python build process creates a Python package in the dist
directory, which can be uploaded to TestPyPI or PyPI.
The script push_tag.sh
is used to push a tag to GitHub, which then triggers a GitHub Actions workflow to create a GitHub release and to publish the package to TestPyPI or PyPI. Note that tags are GitHub repository specific.
You can create a conda environment with:
conda env create -y -f environment.yml
Activate the environment with:
conda activate jcircuit
You can create and activate an npm environment with:
nodeenv node_env
# source node_env/bin/activate # linux
# Windows is more complicated, but these 2 lines should work:
export NODE_VIRTUAL_ENV=${PWD}/node_env
export PATH=${NODE_VIRTUAL_ENV}/Scripts:${PATH}
Install the npm dependencies with:
npm install
Build the Javascript module with:
npm run build
Build the Python package with:
python -m build
Upload to TestPyPI manually with:
python -m twine upload --repository testpypi dist/*
Upload to PyPI (production) manually with:
python -m twine upload dist/*
You can use the push_tag.sh
script to push a tag to GitHub. This will trigger a GitHub Actions workflow to create a GitHub release and to publish to TestPyPI or PyPI.
./push_tag.sh --help # for more information
./push_tag.sh [pypi|testpypi] # default is testpypi