Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 2.74 KB

DEVELOPMENT.md

File metadata and controls

110 lines (75 loc) · 2.74 KB

Welcome to the tket2 development guide

This guide is intended to help you get started with developing tket2.

If you find any errors or omissions in this document, please open an issue!

#️⃣ Setting up the development environment

You can setup the development environment in two ways:

The Nix way

The easiest way to setup the development environment is to use the provided devenv.nix file. This will setup a development shell with all the required dependencies.

To use this, you will need to install devenv. Once you have it running, open a shell with:

devenv shell

All the required dependencies should be available. You can automate loading the shell by setting up direnv.

Manual setup

To setup the environment manually you will need:

If you are testing the tkcxx feature to bind to TKET-1, you will need to setup the tket-rs bindings. This requires configuring conan for the project, see the TKET-rs readme for more details.

You can use the git hook in .github/pre-commit to automatically run the test and check formatting before commiting. To install it, run:

cp .github/pre-commit .git/hooks/pre-commit
# Or, to check before pushing instead
cp .github/pre-commit .git/hooks/pre-push

🏃 Running the tests

To compile and test the rust code, run:

cargo build
cargo test

Run the benchmarks with:

cargo bench

Finally, if you have rust nightly installed, you can run miri to detect undefined behaviour in the code. Note that the devenv shell only has rust stable available.

cargo +nightly miri test

To run the python tests, run:

cd pyrs
maturin develop
pytest

💅 Coding Style

The rustfmt tool is used to enforce a consistent rust coding style. The CI will fail if the code is not formatted correctly. Python code is formatted with black.

To format your code, run:

# Format rust code
cargo fmt
# Format python code
black .

We also check for clippy warnings, which are a set of linting rules for rust. To run clippy, run:

cargo clippy

# Include code not compiled in the main build
cargo clippy --all-targets