-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dfae57
commit 7220b48
Showing
29 changed files
with
591 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: build with nix | ||
on: | ||
schedule: | ||
# 01:00 every Sunday morning | ||
- cron: '0 1 * * 0' | ||
workflow_dispatch: {} | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
build_and_test: | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-22.04', 'macos-12'] | ||
runs-on: ${{matrix.os}} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cachix/install-nix-action@v20 | ||
- name: Build and test tket | ||
run: nix flake check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.egg-info | ||
*.o | ||
*.so | ||
*.swp | ||
.cache | ||
.eggs | ||
.hypothesis | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
description = "Tket Quantum SDK"; | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ | ||
(import ./nix-support/libs.nix) | ||
(import ./nix-support/symengine.nix) | ||
(import ./nix-support/tket.nix) | ||
(import ./nix-support/third-party-python-packages.nix) | ||
(import ./nix-support/pytket.nix) | ||
]; | ||
}; | ||
in { | ||
packages = { | ||
tket = pkgs.tket; | ||
pytket = pkgs.pytket; | ||
}; | ||
devShells = { | ||
default = pkgs.mkShell { buildInputs = [ pkgs.tket pkgs.pytket ]; }; | ||
}; | ||
checks = { | ||
tket-tests = pkgs.run-tket-tests; | ||
pytket-tests = pkgs.pytket; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Nix support for tket and pytket | ||
|
||
Tket exposes a Nix flake that you can build, test and use within a Nix environment. | ||
To build and test tket and pytket on your local system, you can run | ||
|
||
``` | ||
$ nix flake check github:CQCL/tket | ||
``` | ||
|
||
This will take some time, as it requires the building of a patched symengine, | ||
the compilation of tket and tket tests, and the compilation of pytket's dependencies, | ||
before testing. | ||
|
||
You can enter a development environment with tket and pytket available | ||
with use of `nix develop`. For example, | ||
|
||
``` | ||
$ nix develop github:CQCL/tket | ||
$ python3 | ||
Python 3.10.12 (main, Jun 6 2023, 22:43:10) [GCC 12.2.0] on linux | ||
Type "help", "copyright", "credits" or "license" for more information. | ||
>>> from pytket import Circuit | ||
>>> circuit = Circuit(5) | ||
>>> circuit.X(1) | ||
[X q[1]; ] | ||
>>> circuit.X(2) | ||
[X q[1]; X q[2]; ] | ||
``` | ||
|
||
You can also use tket and pytket within your own flake project. | ||
An example of such a project is given in the [example-flake-project](example-flake-project) | ||
directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Example flake project | ||
|
||
In this example, we create a [flake.nix](flake.nix) file that tells Nix | ||
where to fetch nixpkgs, flake-utils and tket. It also builds an example | ||
application, using [pyproject.toml](pyproject.toml) and the | ||
[src](src) directory. This application [exposes](src/examples/basic_circuits.py) | ||
two scripts: `entanglement` and `teleport`, that set up trivial circuits | ||
and display them in your browser. | ||
|
||
To run these scripts, simply run the following commands from within this directory: | ||
|
||
``` | ||
nix run .#entanglement | ||
``` | ||
and | ||
``` | ||
nix run .#teleport | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
# fetch tket from github | ||
inputs.tket.url = "github:CQCL/tket"; | ||
|
||
outputs = { self, nixpkgs, flake-utils, tket }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ | ||
(self: super: { | ||
# add tket and pytket to pkgs for later use | ||
tket = tket.packages.${system}.tket; | ||
pytket = tket.packages.${system}.pytket; | ||
}) | ||
]; | ||
}; | ||
examples = pkgs.python3Packages.buildPythonApplication { | ||
pname = "examples"; | ||
version = "0.0.1"; | ||
format = "pyproject"; | ||
# copy pyproject.toml and src to the build directory | ||
unpackPhase = '' | ||
cp ${./pyproject.toml} pyproject.toml | ||
cp -r ${./src} src | ||
chmod 700 src; | ||
''; | ||
# provide pytket as a dependency | ||
propagatedBuildInputs = [ pkgs.pytket ]; | ||
}; | ||
in { | ||
apps = { | ||
entanglement = { | ||
type = "app"; | ||
program = "${examples}/bin/entanglement"; | ||
}; | ||
teleport = { | ||
type = "app"; | ||
program = "${examples}/bin/teleport"; | ||
}; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
name = "examples" | ||
version = "0.0.1" | ||
dependencies = ["pytket"] | ||
|
||
[project.scripts] | ||
entanglement = "examples.basic_circuits:entanglement_circuit" | ||
teleport = "examples.basic_circuits:teleport_circuit" | ||
|
Empty file.
Oops, something went wrong.