libqasm Python Package
Project description
libQASM: Library to parse cQASM v3.0 files
File organization
For development, see:
include
: public headers.src
: source files.test
: test files.python
: SWIG interface.res
: resource files, for testing.
For build process, continuous integration, and documentation:
conan
: Conan profiles.emscripten
: bindings and test for the emscripten binaries.scripts
: helper scripts used during the build process..github
: GitHub Actions configuration files.doc
: documentation.
Build outputs may go into:
build/<build type>
: the C++ library output files generated by Conan.pybuild
: the Python library output files generated bysetup.py
.
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 zulu-opendjk
Conan package on an ARMv8 architecture.
zulu-openjdk
provides the Java JRE required by the ANTLR generator.
So, for the time being, we are installing Java manually for this platform.
Java 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:a=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](-build_type)(-compiler)(-os)(-arch)[-shared]
naming convention:
tests
: if tests are being built.build_type
: can bedebug
orrelease
.compiler
:apple-clang
,clang
,gcc
,msvc
.os
:emscripten
,linux
,macos
,windows
.arch
:arm64
,wasm
,x64
.shared
: if the library is being built in shared mode.
All the profiles set the C++ standard to 20.
All the tests
, except for linux-x64
profiles, enable Address Sanitizer.
Build options
Profiles are a shorthand for command line options. The command above could be written, similarly, as:
conan build . -s:a compiler.cppstd=20 -s:a libqasm/*:build_type=Debug -o libqasm/*:build_tests=True -o libqasm/*:asan_enabled=True -b missing
This is the list of options that could be specified either in a profile or in the command line:
libqasm/*:asan_enabled={True,False}
: enables Address Sanitizer.libqasm/*:build_type={Debug,Release}
: builds in debug or release mode.libqasm/*:shared={True,False}
: builds a shared object library instead of a static library, if applicable.
Tests are enabled by default. To disable them, use -c tools.build:skip_test=True
.
Install
From Python
Install from the project root directory as follows:
python3 -m pip install --verbose .
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.6.6 . -pr:a=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
The libqasm
module should provide access to the V3xAnalyzer
API:
parse_file
,parse_string
,analyze_file
, andanalyzer_string
.
The cqasm.v3x
module is also available for a more fine-grained use of the library.
import cqasm.v3x.ast
import cqasm.v3x.instruction
import cqasm.v3x.primitives
import cqasm.v3x.semantic
import cqasm.v3x.types
import cqasm.v3x.values
From C++
libqasm
can be requested as a Conan package from a conanfile.py
.
def build_requirements(self):
self.tool_requires("libqasm/0.6.5")
def requirements(self):
self.requires("libqasm/0.6.5")
And then linked against from a CMakeLists.txt
:
target_link_libraries(<your target> PUBLIC libqasm::libqasm)
Note that the following dependency is required for libqasm
to build:
Java JRE
>= 11
The header file cqasm.hpp
should provide access to the following API:
cqasm::v3x::analyze_file
, andcqasm::v3x::analyze_string
.
Again, other header files are available for a more fine-grained use of the library.
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 due 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
Emscripten
The generation of emscripten binaries has been tested as a cross-compilation from an ubuntu/x64 platform.
conan build . -pr=conan/profiles/release-clang-emscripten-wasm -pr:b=conan/profiles/release -b missing
The output of this build lives in build/Release/emscripten
:
cqasm_emscripten.js
.cqasm_emscripten.wasm
.
Note that cqasm_emscripten.js
is an ES6 module. An example of how to use it would be:
cd build/Release/emscripten
mv cqasm_emscripten.js cqasm_emscripten.mjs
cd ../../../emscripten
deno run -A test_libqasm.ts
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.6.6-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6a1a15a982a04e9e2f4eac54efa56cef451295ecbd6d2136bbace7fe06fd900 |
|
MD5 | d714d2bc70e5f3f97d9527b7adc245a8 |
|
BLAKE2b-256 | 932059447f0247f16cf8781f0d6ae34732e7bcbf2d34d65c720d840663903303 |
Hashes for libqasm-0.6.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3edbd092668662bab54d39632c5fb7ce8eee952343561ca43afaa1fd2ad67b1a |
|
MD5 | e1f5ffbea29f3135c246e088db67b066 |
|
BLAKE2b-256 | 0ead7815cac044fd7075a6e9f526cc5e2fdd8c1eb8d8dc14d6cfc6f8fc004bda |
Hashes for libqasm-0.6.6-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7c6c58ce4f55559cabdb41b0c808d52009d394af5a63a43e6deea7c43a18cde |
|
MD5 | 3704d9ef29e0255172ceb8e8f5833b83 |
|
BLAKE2b-256 | df5bc3a2352c9a858714f40643a3b0ab2d5d8e2c7fbbe53680243a4a2fb250be |
Hashes for libqasm-0.6.6-cp312-cp312-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39a65c8b91b3ec8d6d9986d7c20975653a1cfd3031a05b0032f75a5fde073c29 |
|
MD5 | a64d78dc920c2a04edb1212a4fb5bd59 |
|
BLAKE2b-256 | 1e84f3ea087f7006cdcc14e81f4c0a7a1853fefef224b5bba0c86b45111b74f9 |
Hashes for libqasm-0.6.6-cp312-cp312-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e217987fbec408094a4556f9f79f1fc03919a249b1005c216f02990e32289ba |
|
MD5 | 16667fd6841871fbf493031768a53eab |
|
BLAKE2b-256 | 053b24e1cba1edf57575f53b9ffa9b6e9d93fab6d4846a156bc4cd4b333aeb30 |
Hashes for libqasm-0.6.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59ceda3d21abfd53a712837d9d502fd53566effe095aaa390c29d4765b70688f |
|
MD5 | d689957458c69d9743e702b291f5b4df |
|
BLAKE2b-256 | 34506da107e98d04d818076e39fb8cc368edc5e42933f62b382a89f7de1c97c0 |
Hashes for libqasm-0.6.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30c917e10847385d6c01981723f96b3c39882e99b44e2e6d38c525f492c321fa |
|
MD5 | acb4197e6be12b52f6a5c16104208085 |
|
BLAKE2b-256 | cc8b1a67eade6738e62eeef6c5842700d137f24081efcd13141d75333a6212ec |
Hashes for libqasm-0.6.6-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f7f959a482dc74912f7e6fd45878f7f7b5dafeb66e87098cb3d9470b0f97cde |
|
MD5 | 993b13c631accebe70403d0136bde2db |
|
BLAKE2b-256 | 2861637b157553391ddb4f2f7c7fe9b8e814cb8acfb94e1de6e75ccb15306bf0 |
Hashes for libqasm-0.6.6-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44309ed847730890a2753f03e58fea26e7d51cf6d8db96f147bddcd41fae2648 |
|
MD5 | a620000a3fe224d1aac840fef2e50240 |
|
BLAKE2b-256 | 59a31087be88556c382bd873d8d6e63f1682a3a71ff69bc2c4e34cf881027def |
Hashes for libqasm-0.6.6-cp311-cp311-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa3a1f6963d549c56bdd2835cdaa0c32ea2d98e53071a297d4d98982190b4894 |
|
MD5 | c72e0a7fe45d5c1e584c154bce4493aa |
|
BLAKE2b-256 | d9d547a905a58bc87d4728621564cb49f28d4417f219e64cd9c8b570b1b98bed |
Hashes for libqasm-0.6.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333519170c3b0928bf0268c72ccd35ed31b23e95fda1771863c6f09cecae967a |
|
MD5 | 38d17c7f90e5abd5dc576262f1963193 |
|
BLAKE2b-256 | df916f60ae05ec18337ceb425b425f416e47cefe623d1679052f2aa7b736b3d0 |
Hashes for libqasm-0.6.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce85489d7b2037034a5290038df1f1f98fea7cf63f02bd85e32315b933e6ed2a |
|
MD5 | d78fdde79273d3e5cbfd66bdd2e96e76 |
|
BLAKE2b-256 | 4030f935d71516ad4f72ff5b73a09918acb8bd859778c4ad7be003f539826b02 |
Hashes for libqasm-0.6.6-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad2075cca3f67fd3df5af75038d74f2f2b09f6abd77db2097caf6002475806b7 |
|
MD5 | a9b41bf1bd11bbf06adb34e706be53fb |
|
BLAKE2b-256 | ee977f3670c910a5680ddb25cd44ca710243337c1e06b7c4a45c33a5e9aded2d |
Hashes for libqasm-0.6.6-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3febe56ab802da4d7ba2c98ad13915d16b7abf1c931dc86cb32f60504d86ef10 |
|
MD5 | 037ef80dbbd58d780d35507f89f0be85 |
|
BLAKE2b-256 | 4bffc44fc20b7d0ed71b60905e6cff528a3230bc7afb6e16d72a7a7915423bbf |
Hashes for libqasm-0.6.6-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f7e0bf4a5086d24b23f62462ab5fa2c78358d2f0bc89f7440b66a11511ec908 |
|
MD5 | 171272493f739288fa553f54bface903 |
|
BLAKE2b-256 | 85f80214ce5d466c4f29a7a83a35b9038e9d4382bbeb5bcce16d158daaef6663 |
Hashes for libqasm-0.6.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e3aaf3471be7d10332a3dd4f7e84e074aebaa040c8d6996a156ecc50e4cf430 |
|
MD5 | cf56e9c8f0e94e38eeedc4f3a73b716c |
|
BLAKE2b-256 | 37abb35d59347776072c1dde2c7a0dae148716e63af708bdee407738043b9070 |
Hashes for libqasm-0.6.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 026d1ef42567294557ba55fd7db7a6f9b7d5f434c96906b37f4e33e09f2feb0c |
|
MD5 | bc6f75bd2980694fdd32c18be68e2234 |
|
BLAKE2b-256 | 4c05bc4ae874028c3143e6e928f991b9bb03120d7123db104cce0499306be4b3 |
Hashes for libqasm-0.6.6-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0700e0c971ae8da045696300588ef2d56a3c8aa39140a44e344630a2e8ba030e |
|
MD5 | 00e9d712eb8797f342b41f7eb0dddc12 |
|
BLAKE2b-256 | 4e070a865ceaf034e64eff9f98c1561233b36bfd0ff5281d66033a72fb7e483b |
Hashes for libqasm-0.6.6-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 213e0b029f6b277a3068a9864c13653a782caf9ce1bb2b648b2ad7bae866a6ff |
|
MD5 | a75de2a1554a2212c74641ba27b50c46 |
|
BLAKE2b-256 | 91d13ac89c9a8cb6e776972c78b3d9fcf20c2bdeea232519f806b8ac6eb071ff |
Hashes for libqasm-0.6.6-cp39-cp39-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a61e271bbb0e6d26f3782555f405bb83323c2501fdd2b77b0760392ef3e0540 |
|
MD5 | a4eff47fac9d6f99dc67d20eac45e985 |
|
BLAKE2b-256 | edee899a83b0175e3b2f9bbe9afc8656d9028fef7999804d39a5397666ef1e3d |
Hashes for libqasm-0.6.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c311672f7fd8d048ee2cd2bb0d43a2e86a78613d5951afc3ec26f74b1850f09 |
|
MD5 | 06be2f8115f3d0d1cf29022acd10254d |
|
BLAKE2b-256 | c3dd3903109235ec4dc137205ff4d69813fde13a3a771db3f62beedfddae4131 |
Hashes for libqasm-0.6.6-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d00cc65e29dbadec3b8e464d9e6078726cec11401d504b7abc1b5798b785db2 |
|
MD5 | a14b2047b2c2c09554dc7388a226d77e |
|
BLAKE2b-256 | ba258dee5bef285d8f15332b2d460594394e9f2cf60eca8a74fcd08a73653238 |
Hashes for libqasm-0.6.6-cp38-cp38-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 231339d32b30142af8f01190ab1f587f9f2b3f1ea70953868e5a5009b5045d01 |
|
MD5 | 5909fe406d40b2333b3c6a76e3724574 |
|
BLAKE2b-256 | 02a675ee020e4caef291c28a2e4347da573c604c041d64bc76910afb46091b55 |
Hashes for libqasm-0.6.6-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 649e2bdf490fc2153c406f008ca0cc937013280a2c29fdc297ddbdcfd5f0d23b |
|
MD5 | deea12a592c026666c3d3bb82c147f14 |
|
BLAKE2b-256 | 9fabc5cb39940071d849695ce5c6d5e004811e9530c4ed538cb0cc2f36b74299 |
Hashes for libqasm-0.6.6-cp38-cp38-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eae1f527a8027454e3cd32e4b358238ce8d082d93ed5dd4b7b2e426593b8bd8 |
|
MD5 | a2a8149456b2795a42e5e9bdcd4c75ae |
|
BLAKE2b-256 | e4b4572e32aa25b8d535a3230cf0da5a988b350b33456b3c7396d47e85b412ba |