libQasm Python Package
Project description
libQASM: Library to parse cQASM v1.0 files
File organization
The original paper and BNF specification for the cQASM v1.0 are located in the doc/v10
directory.
Please note however that the language has changed to some degree since then,
and the qasm.bnf
has never fully corresponded with the flex/bison grammar.
There are currently two C++ API versions contained in this repository:
a new API (v1.2) and the original API (v1.0) maintained for backward compatibility purposes.
The new API lives in v1x
directories, and the older API in v10
directories.
src/v1x
: sources of the new API, and the grammar files for flex/bison.include/v1x
: headers of the new API.include/v10
: compatibility layer for the original API, now built on top of the new API instead of the original flex/bison parser.test/v1x
: tests for the new API.test/v10
: tests for the original API, as well as its Python bindings.
The following folders may be generated:
build/<build type>
: the C++ library output files generated by Conan.pybuild
: the Python library output files generated bysetup.py
.
WIP: cQASM v3.0
We have started working on the parsing of cQASM v3.0 files, and that's why you will also see some v3x
folders around.
However, the development of the new parser is still in a very early stage so its use through the API is completely unsupported.
Dependencies
- C++ compiler with C++20 support (gcc 11, clang 14, msvc 17)
CMake
>= 3.12git
Python
3.x pluspip
, with the following package:conan
>= 2.0
ARM specific dependencies
We are having problems when using the m4
and zulu-opendjk
Conan packages on an ARMv8 architecture.
m4
is required by Flex/Bison and zulu-openjdk
provides the Java JRE required by the ANTLR generator.
So, for the time being, we are installing Flex/Bison and Java manually for this platform.
Flex
>= 2.6.4Bison
>= 3.0Java JRE
>= 11
Build
This version of libqasm
can only be compiled via the Conan package manager.
You'll need to create a default profile before using it for the first time.
The installation of dependencies, as well as the compilation, can be done in one go.
git clone https://github.com/QuTech-Delft/libqasm.git
cd libqasm
conan profile detect
conan build . -pr=conan/profiles/tests-debug -b missing
Notice:
- the
conan profile
command only has to be run only once, and not before every build. - the
conan build
command is buildinglibqasm
in Debug mode with tests using thetests-debug
profile. - the
-b missing
parameter asksconan
to build packages from sources in case it cannot find the binary packages for the current configuration (platform, OS, compiler, build type...).
Build profiles
A group of predefined profiles is provided under the conan/profiles
folder.
They follow the [tests-](debug|release)[-compat]
naming convention. For example:
release
is a Release build without tests and compatibility with the original API.tests-debug-compat
is a Debug build with tests and compatibility enabled.
All the profiles set the C++ standard to 20. All the tests
profiles enable Address Sanitizer.
Build options
Profiles are a shorthand for command line options. The command above could be written as well as:
conan build . -s:h compiler.cppstd=20 -s:h libqasm/*:build_type=Debug -o libqasm/*:asan_enabled=True -o libqasm/*:build_tests=True -o libqasm/*:compat=False -b missing
These are the list of options that could be specified whether in a profile or in the command line:
libqasm/*:build_tests={True,False}
: builds tests or not.libqasm/*:build_type={Debug,Release}
: builds in debug or release mode.libqasm/*:asan_enabled={True,False}
: enables Address Sanitizer.libqasm/*:compat={True,False}
: enables installation of the headers for the original API, on top of the ones for the new API.libqasm/*:shared={True,False}
: builds a shared object library instead of a static library, if applicable.
Install
From Python
Install from the project root directory as follows:
python3 -m pip install --verbose .
or if you'd rather use conda:
conda build python/conda
conda install libqasm --use-local
You can test if it works by running:
python3 -m pytest
From C++
The CMakeLists.txt
file in the root directory includes install targets:
conan create --version 0.4.1 . -pr=tests-debug -b missing
You can test if it works by doing:
cd test/Debug
ctest -C Debug --output-on-failure
Use from another project
From Python
After installation, you should be able to use the bindings for the original API by just import libQasm
.
The new API doesn't have Python bindings yet.
From C++
The easiest way to use libqasm
in a CMake project is to fetch the library and then link against it.
include(FetchContent)
FetchContent_Declare(cqasm
GIT_REPOSITORY https://github.com/QuTech-Delft/libqasm.git
GIT_TAG "<a given cqasm git tag>"
)
FetchContent_MakeAvailable(cqasm)
target_include_directories(<your target> SYSTEM PRIVATE "${cqasm_SOURCE_DIR}/include")
target_link_libraries(<your target> PUBLIC cqasm)
Note that the following dependencies are required for libqasm
to build:
Flex
>= 2.6.4Bison
>= 3.0Java JRE
>= 11
The original API headers are not included by default.
To enable those, pass -o libqasm/*:compat=True
as a build option to Conan.
Docker
This tests the library in a container with the bare minimum requirements for libqasm
.
docker build .
Note for Windows users: The above might fail on Windows to the autocrlf transformation that git does. If you are having trouble with this just create new clone of this repository using:
git clone --config core.autocrlf=input git@github.com:QuTech-Delft/libqasm.git
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 Distributions
Built Distributions
Hashes for libqasm-0.5.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 891aa482cccafd005787a5975ec2c6b82535e35f1162b979153e1c8fcbc10c3e |
|
MD5 | 2aacbfc12b2d8775142aa6857e289551 |
|
BLAKE2b-256 | 9e1df63407c9c8957c9c5fd51fee2a0f6c37c288a9ce9ceb441f69b7f5e6cab5 |
Hashes for libqasm-0.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e87d0078f397ee83e6ee9ba56ab2115bde63e63cb431f3a34ac008f72f16a5f |
|
MD5 | 3d55e2f1bb741585d0b77b3a0e03830f |
|
BLAKE2b-256 | 795423b747c5bc1b8f771ecbb94451bc7b10621b5bf205e732702f7f8e1d30bb |
Hashes for libqasm-0.5.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b92134092d970ced2b7f3dd51db4798fa7739fc981cdfd9ce700d25f9b0bbe5 |
|
MD5 | b9bbece681cf27eed8afb9a9f60aef8d |
|
BLAKE2b-256 | 205ec3eb0c4d9f9ed04ec8bbea63927a1b325bc12c34d633faf4adcab52bf8fd |
Hashes for libqasm-0.5.1-cp312-cp312-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54dbed10a04022ae0569a96fdcb08a7bf931ce656c2f8cc630445267af963d40 |
|
MD5 | ca7781771ccf95344d4e461728ad9d6a |
|
BLAKE2b-256 | edcc54e77f87eda27e8768ca337c765f1333d27cac49b5801ce7fec7b243ca15 |
Hashes for libqasm-0.5.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 534b69c7fe5f9dfbc51807698ec51d79e10e7a1966600292adfc36c7312e1937 |
|
MD5 | 245633aa000fb9559e6d4fcd0fd509e4 |
|
BLAKE2b-256 | eab302205e6622e6d96cabe7d095021dc9d025d7f7793207b2108847a9604fae |
Hashes for libqasm-0.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7b3097f04cedef56791bc1e99c431247cda8308a7401bccc1de85590c64cbc4 |
|
MD5 | 62e0a57d8218e320ae1f1929b98356ca |
|
BLAKE2b-256 | 18a96baeeb21a05122ef4f1a80dcd1059aac0a9324b1950e20e7a448314ae783 |
Hashes for libqasm-0.5.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b96b5d67876e0c214672f06d516df99fa25d01cc8f814cf5f7a3d4a1febbda |
|
MD5 | bf96b7dc50841ec585a0258b505a7090 |
|
BLAKE2b-256 | 2bfcd0cd0521037bd0a909c87caddb41915194a31288055e91e01b81e643aaea |
Hashes for libqasm-0.5.1-cp311-cp311-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b70c56d276e50d500858d80c0bc88c3e180edc1d56c79dec5d0286927b6ace6 |
|
MD5 | 1f5c207588645d82a5eb228d2b1d7859 |
|
BLAKE2b-256 | d63f7164a575ec15633cebafcc8c06b301bbcc4163ba102d4cf1bc897517f27e |
Hashes for libqasm-0.5.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068ffa2c47c72f5638935fc543c5b8ec76c91d86ebe1e768f4f6c53c04d3a5b0 |
|
MD5 | 47acc4f2377b5741a106aac969d4d2d3 |
|
BLAKE2b-256 | 69c0d4233c946682d0dc463847cc2380add4ef6c4d79f18284cb520392549769 |
Hashes for libqasm-0.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03aa930e7ea6f7e6590b244bfa03d9b8dbd383ea28370d56480c1e0fbdf139ac |
|
MD5 | 6b11acd5f82498059975f1a58c2c4e94 |
|
BLAKE2b-256 | f7d38262470620b9059a901bbfa0abdd5f14a9d5760860b2a4fa2df6feea167a |
Hashes for libqasm-0.5.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f47c8d1d57fcf556fe611ff37848f95209378ac0268c112a5a5a7c4ee5216b2 |
|
MD5 | 2b97312729fa300d30e5420a7a3e480a |
|
BLAKE2b-256 | 31647d63aada600e6ff2295e996a3e520f00855e778222eff286607f76305273 |
Hashes for libqasm-0.5.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb7640f764c717056ba93ef72863a43428dbe229b18de4542fb79418bd04b41 |
|
MD5 | 4d567429a398ae528d8edf4680598e3e |
|
BLAKE2b-256 | 133f93953495797b4c4eba5945f7a3aad8313aa7ad5695ad862fdb6d2dae5e93 |
Hashes for libqasm-0.5.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beceeea001c05c4924834e5c1ae94e9f807578a7989f32bf095ccb8392fecc9b |
|
MD5 | b3adc0248bb8a351e4a807f5ca58672f |
|
BLAKE2b-256 | 2e340c81a8bb1506a953c4316bc5969f70ab244f2b5683f740715c4e0a1832f1 |
Hashes for libqasm-0.5.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 595eee94d557705a46426b7db679162c81d73b8143613c0ddd2e18e31d8792d1 |
|
MD5 | 1552ef12c1c70aba4bdb0952a369c9af |
|
BLAKE2b-256 | 90e77fbf5e5f29eb7454bbf3ddefd5b624e18ccc6e6aed43d2e8499f74c334b5 |
Hashes for libqasm-0.5.1-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b04fdf37cd773efbaeddb72073d3a001852bd0ca090ebd640ac8de0208dab904 |
|
MD5 | 7150c9ebf19f0ea41ce5820ca36c60f5 |
|
BLAKE2b-256 | 31a5786b204de322b4eb75a83399dc5adabcfb4f41d9eaa980f2cbc293d56d25 |
Hashes for libqasm-0.5.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b651b6b0ded64539dd084dd39ba96e3704ef08b6860b2df878271794a98c23f1 |
|
MD5 | b3434b2c153f2fd6356eb5fa86e1be49 |
|
BLAKE2b-256 | 6d418a2326c36321532c1557b19fa1f0b9de33b0e5412c1460298e8c0550faa0 |
Hashes for libqasm-0.5.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afeaff8adfd3d97ed06723c81c048fb9b5a893b0bce1ab70a7d1e76fb3178660 |
|
MD5 | 8a1dec4957b8bf1f3f8f2c588154d41f |
|
BLAKE2b-256 | ffb4181f3b1e117ae0549160c8c7874320dda664c0bee4763319208e9193b128 |
Hashes for libqasm-0.5.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f03fed1b89b80da5509c77fed0b9a902aca4866267d4db380c1c283a7a25d84d |
|
MD5 | 164f4463cbda11924121dd08844ee83c |
|
BLAKE2b-256 | daa587104dce25e3b89368237d61fc5b5d3389c344ea56ef792a83303f5f309e |
Hashes for libqasm-0.5.1-cp38-cp38-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1693855c2e7a0fbb3e8b44a629cd9a540fc0fe79669ba5a5f3f0c8da307b477 |
|
MD5 | d4870909458f15d3f9f1cfdc2ebc59ed |
|
BLAKE2b-256 | 813f0b637b81ebb497d4d98f20e60dfa2242808e51ed9e48bb9b635b9928473f |
Hashes for libqasm-0.5.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a15b246f6b929196f17a44f6ec02f1c28ff9e41ac00e6b59ab09a31efa1275e9 |
|
MD5 | 16d0b7ddc48f1e18a063b268495b9d6a |
|
BLAKE2b-256 | 494141f64d1493590fbea18bc7050b66be81ed414530e8879692396cc2d07d12 |