Skip to main content

Python module for simplicityhl compiler

Project description

pysimplicityhl

a python wrapper for the simplicityhl compiler

Usage

run pysimplicityhl.run_from_python to call the SimplicityHL compiler like this:

import os
import json
import pysimplicityhl

if __name__ == "__main__":
    basedir = os.path.dirname(__file__)
    hl_file = f"'{basedir}/simple.hl'" # contains only a dummy "fn main() {}"
    parameter = [
        "--debug",
        f"{hl_file}",
    ]
    parameter_str = " ".join(parameter) # one single string
    result_json= pysimplicityhl.run_from_python(parameter_str)
    res = json.loads(result_json)
    res["parameter_str"] = parameter_str
    print(json.dumps(res, default=str))

Installation

First build the complete rust project

cargo build

and you should find the binaries in the subfolder target with target folder debug or release.

Now create a python environment ...

python -m venv .venv

... and activate it

. .venv/bin/activate # linux/mac 
. .venv/Scripts/activate # windows (git-bash)

Let poetry add missing libraries with

poetry update

Now build the debug wheel (to be found in folder debug/wheel)

maturin build --manifest-path pysimplicityhl/Cargo.toml

or the release build (to be found in folder relöease/wheel)

maturin build --manifest-path pysimplicityhl/Cargo.toml --release

A quick install (i.e. a forced reinstall) of the newly compiled wheel could look like this, assuming at least one whl file exists.

poetry run pip install --force-reinstall "$(ls -t target/wheels/pysimplicityhl*.whl | head -n 1)"

If you want to do all at once you may test this poe command (make sure the venv is activated)

poetry run poe build-wheel

Test

in the demo folder you will several simplicityHL test files like e.g. the demo file demo/simple.hl which looks like this:

fn main() {}

this example will compile to the binary JA== signifying an empty simplicity program.

Running

poetry run python demo/main.py

and should give the results of several test simplicity files being compiled

{
  "status": "success",
  "program": "JA==",
  "parameter_str": "--debug './pysimplicityhl/demo/simple.hl'"
}
{
  "status": "success",
  "program": "4EkhxS8Oa67l4PQnU9GQOM5f425K8oynz2VMtqrT2Wu0YojxUYhwwDELM4oFrbGHM4qiEiuhMwARVwsGLwpYT2BhULrCX64qRkLLDgFbd+AIYBiA",
  "witness": "m++NVW2A5Drn4L7LOn5oOLld7+RYlu1gdbuQNdBsmWRsMTsdPMpjnzMgUiD3LILjdVAYPbBV2h+dtuKPOUguR+U63L7LFh9S0iwNxyt4jytek6RFu6owclyxFl8DzezI",
  "parameter_str": "--debug './pysimplicityhl/demo/p2pk.hl' './pysimplicityhl/demo/p2pk.wit'"
}
{
  "status": "success",
  "program": "5yHQKHQKHQKHQKEGHHHIMFSbFlQAQgUJIQYKvKcwYulQXr0Fu/BAWgC5j7LWeBAl+pI9pt9ZFn0rcXaN1FhgGI3Bzj8EOFROCCcF4cziqISK6EzABFXCwYvClhPYGFQusJfripGQssOAVt34AhgGIThCSD7zcTig/ABQLJsYc113LwehOp6MgcZy/xtyV5RlPnsqZbVWnstdoxRHioxDhgGITafj0EA4CBwoJxSBiLiIBmDi4DjQgxAoNyAOOONx+KBcX8WgcDE5AAcHBiNyLOOE1JIEnwxOZ+Cq1myCZY7Ax/Klosw4w/YaiSrNDaOhM/+erWaIc9xgwDFZAAAAAQNIVC1M24nMERf6gONImmAwub35L6eiVhI0f2X8hANtDAEy06t3vxQYBiFwBg5gXe+1Cj7rQ+ji6QJDRW0vEmFLGZXcRhKAN6Nt0/l2ADDAMXw4Ic3idDCRwDPfEbxc9Hgqw6MFFnfB5SG98/3X6ptShJKOWBgHCQnLZJFkAAAAAAoVfDUc2gh0FinqrkqEEWyo/WTDVDT/U2bJS9gAmPKXAmHgCyTBgGIWkhIoZ0QznIWef/b40z+a+nNzThyQhoT+7cjE0KYRLTvzYTFwuXQKObvJWcC0jz5LzKXn0/Nn/OQnPezJTiq+w46I+xAB5sdEwwDUE5iUkC5guQgozboObaVZ2p0jgwi+XQBxtGGWFy+/xoSyiAw9mWEcVuKG05XwwDELQb6EE/c3ifyUoNc1ZzkPnUg6gZ3G/jPcz7k+eRVKFshBw8VgVZAAAAAINwW58NhzSoNzoMc1Ae/7Z55CGHj0gOG/ZVBjb5kbDqY2kAJh07WGAYhcEISKEGB4jAwHMDLqyIAl/t8mPC4rRGEfM1lVH7CAxNfptKDrOKJGwAHAYBrC4gNL6lcZ9HTU3CRlRyCoGVZzuEYuSi/jp604WRZrD9L3pYeQYFCcSgcthcLAcuAcVAcgQuRADl4DmnCc1AHL8XKsBzAg5TA8qwOW4PLwDm5A5vQOcEDnFA==",
  "witness": "eb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5jGBH+UQe19bTBFQG6VwHzYXHeOS4zvPKerrAm5XHCe5fkwigGSWMMQSTRPhfidUim1MchFg2+ZsIYB8RO84Db5OqkA3bFYVFxox+iX4BSo9RzMXSFf4zMm1XxQaRTGVqHm4QmsY+QXm7KhOu4X9UZCxW30vdZJQUWkxS0RuAJtt4A=",
  "parameter_str": "--debug './pysimplicityhl/demo/lastwill.hl' './pysimplicityhl/demo/lastwill.wit'"
}

Important

Windows users should note the surrounded quotes when stating filenames with full path (see output key parameter_str)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pysimplicityhl-0.3.6-cp312-cp312-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.12Windows x86-64

pysimplicityhl-0.3.6-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysimplicityhl-0.3.6-cp311-cp311-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.11Windows x86-64

pysimplicityhl-0.3.6-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysimplicityhl-0.3.6-cp310-cp310-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.10Windows x86-64

pysimplicityhl-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pysimplicityhl-0.3.6-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysimplicityhl-0.3.6-cp39-cp39-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.9Windows x86-64

pysimplicityhl-0.3.6-cp39-cp39-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pysimplicityhl-0.3.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d7bf9d30adecefb7c6a65ce7a2cce3849fc4e79faff2f82be712245ed0bb0b30
MD5 569012520bca2f9ee44700eeea909652
BLAKE2b-256 406c160a84ad7a5a7ff8fd466e4cf24209d05b127b87e58c49d5f28bc4b06ad5

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79c5b7046cbb344a20fa92a8f049be0498bc952fe68d24274cec0adb65244ff2
MD5 45145dac13fffb456f3596e8493050fc
BLAKE2b-256 e3ba9ece99b0643f763c14fbc90e237235a451ef207da61dde84e030b797573e

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 365ad4ad6f56f4017a8a10cb4cd2261e6e752b7952a4af5835c07ec1068f0796
MD5 a4ffe824f6f1701a65e2bc90a4d44e01
BLAKE2b-256 6af0511f465dd0a96ed0267ace6d690bab9123646384df8c882faa60e13ce279

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e4905b129c1af3d8527baae912bbc087df73f02f3a7c96e4e8e1c745a9db849
MD5 cb1ab1afff71e01ee3d868117e0dc565
BLAKE2b-256 c2b51e63fb611dafd98585054994ea586c9ef0f4fd6ad026a3c176a2f1b3125d

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 52db84ac8f4b62b8990e25fc0cf28f9c2edc70d1ba85f7da54552acdc5217b90
MD5 1816434024dc225558b5d8ca40449b7e
BLAKE2b-256 94f211a43e3ec62cdcddb40a02e731c9886534c47a7c7c0ce3b2c010a92f775c

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6753bf1fa6c50f452ab17109274fe8f7ad07ecc97eeb772e1113f942d7cbb554
MD5 f2267ba6aec50637474977da293913b9
BLAKE2b-256 47a7468b0f1f890c6350ab0081c9e22bc7128219f3475fc2710cc57f75fd3841

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2597aed3d1a8805721a9b661dda7ba187773d8b1bff3f32210770eafd2a9e146
MD5 c6ac30b79cdefbe67d943a4818625f96
BLAKE2b-256 0e47b90ce4083a0f75249a407e7bdc4b8ebabe65b7f5eca864b6a3e803228417

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 635bbcb8c7e1c0a4daf797500a8bac9b191711ee060ae68d47564607b6631501
MD5 e69c5ec7b46ca34492a682be6392aec6
BLAKE2b-256 7af370468075c032739a0f4237ec6374918ff6a8039495b3286ac25abc9af019

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.6-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3602d7a05ea428dc60158ecf3d0a9bdc5f2cbccad888cc61d58f6e2489a294a
MD5 52e955d0a0e865530ace987e186a66fe
BLAKE2b-256 b9cb184b8082d4d87291e2210a3393f394efcd682db8102c4daf5bf49288f9c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page