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.7-cp312-cp312-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

pysimplicityhl-0.3.7-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.7-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

pysimplicityhl-0.3.7-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.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5a6f950d3c139a083d9bdab4ecb3b3f8c6b164c4cd055c15d7baa64f8c1592f0
MD5 ef5e2323d7870c18343c7795e78b13a3
BLAKE2b-256 aa32990ac3e0c37938a40b7231cb20176ac1c5d6ae4e245a9e72593d93bba987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05d1042835d822c7dd8982ee95f9bc423fc3e7593cddab4c32f1ddae1e49a38d
MD5 fa1b26e0b6610bf11ceb96658a872f11
BLAKE2b-256 e853225036a241753b23b86210ab40e52a116123148cec7ee9cc9b63c150f079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 33d1f0838f8efa6aa65d0f72b766c6870e88abc29cf2f202ce29bc692884c61f
MD5 9401c4d7786ff34a1f4991fb1e2ca107
BLAKE2b-256 2d4c64533d90b901fb65369426745f391ee7643929692cdda4655ef602683222

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1948106a309db1926711eb14d7f9afbfaeeec4cf330d68d1e315c407f8be8019
MD5 db05024885364776ee8b125a9fe0cf29
BLAKE2b-256 46cad68c19182b65b2bce1187e56e59bc277512e09edb6a3c9625b5935f9aa77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7aebf2d83cd6ce16d34c2f2aa19eb7557898e9dee89625931f7f4d8972513352
MD5 d48daae4306e73464a1079565e4bb8b7
BLAKE2b-256 5847cd6d7284f678b62996e670a04c1a2ab054dfeb63df229de4619dd03799a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec7c9f460b8ac03b4f6b57234190625181168f0e7302808488cac9d2204db415
MD5 7766c748eb22ec41a98fbcdc0b0ab12c
BLAKE2b-256 e9fec65def6c3a325b0e18ffb9285b3beb55123a76766ff0de4d264f70b184f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df227f2eda82bfbb0e3fd5483808516bce050a7275e6a0451ca0d0c552694816
MD5 c23a12dcd6393abef507efd2e4f4e40c
BLAKE2b-256 d4001c56a163d423735acea707856d1f6224fb48607c7cc56f316cfa3e781878

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 24a39aa502700aabfb1f11b9f45bc92876c1cdca0cb65ade37b7c5bfcdbf9c7c
MD5 18fea78cec2c85090188118910accb21
BLAKE2b-256 bdf2e2905957944774b8acc69f542cbe5fc27dd6b742ead6d524df7ee8359525

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4ad02d8bcdc85f4b952845924ae385c5eb8a16f6dd43773e72e1030a9d9179d
MD5 ce090c3852375649d7193ab5fb99a209
BLAKE2b-256 b70efcf13c81b0324b9cd3bdbac82834f42135c74ff186b736e122ba253e03ca

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