This pull request introduces the py2qasm CLI tool to the qlasskit/tools package. The tool is designed to convert Python scripts containing qlassf functions into QASM code. Key features include:
Input Handling: Reads from a specified input file or from stdin.
Entrypoint Specification: Allows users to specify a function as the entrypoint for conversion.
Output Handling: Outputs the result to a specified file or to stdout.
Compiler Options: Supports both internal and tweedledum compilers.
QASM Versions: Provides options for generating QASM code in versions 2.0 and 3.0.
Version and Help Commands: Includes -v/--version to display the qlasskit version and -h/--help for usage instructions.
Changes Made
Implemented the main functionality of the py2qasm tool in qlasskit/tools/py2qasm.py.
Utilized argparse for command-line argument parsing.
Added utility functions for reading input, converting to QASM, and outputting results.
Included test cases in test_tools.py to ensure correct behavior.
Updated setup.py to register the py2qasm entry point.
Test Cases
The following test cases have been added to test_tools.py:
Test for version display.
Test for output to stdout.
Test for specifying an entrypoint function.
Test for output to a file.
Test for reading input from stdin.
Test for generating QASM version 2.0 and 3.0 code.
Description
This pull request introduces the
py2qasm
CLI tool to theqlasskit/tools
package. The tool is designed to convert Python scripts containingqlassf
functions into QASM code. Key features include:-v/--version
to display the qlasskit version and-h/--help
for usage instructions.Changes Made
py2qasm
tool inqlasskit/tools/py2qasm.py
.argparse
for command-line argument parsing.test_tools.py
to ensure correct behavior.setup.py
to register thepy2qasm
entry point.Test Cases
The following test cases have been added to
test_tools.py
:Related Issues
This PR addresses issue #26