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

Uploaded CPython 3.12Windows x86-64

pysimplicityhl-0.3.4-cp312-cp312-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pysimplicityhl-0.3.4-cp311-cp311-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

pysimplicityhl-0.3.4-cp310-cp310-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

pysimplicityhl-0.3.4-cp39-cp39-manylinux_2_34_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7f45fc5d9248566693e6ab590a58b773e3a70d38485b8e292484e276c677640d
MD5 fc496e2135cb1862b276e14c8889eed1
BLAKE2b-256 269ab9343338eda65e38a0b635f4daec386d309efc6fe5b6bd9f9a9eb90de760

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.4-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 50b789451cca8b7a6fcaa413c5086312a5b6aaeaff7407ca09205384b6a8b7d6
MD5 d643e11ade0aafa305bd2d1924638962
BLAKE2b-256 ea0baafb9b49f115046c0294532be0f0e45df5f18fbf0b99d7e63880c4ee3c8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8cfd8d3e8542f11f35e76d4f7e44617766e822f938e0657df0f0eb2d8522c6fc
MD5 b1ebfc8d04edbcbdfd064ed5984969d9
BLAKE2b-256 3376094790dd3d9d71a8a0579f0310a16e7d10f79ffcd8c5177247cf9ffe3168

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2df37dcddc5ab402a02b1b5b634f46ca5c7d4206e73e7e9d697a533b785fba0b
MD5 f2345ff791dda72dbcd4d14bfd2b7eb9
BLAKE2b-256 6c8a6d444f7d1530d2c3f03c1a5d766d00e28b9fc0efeafcc1d692a537e33783

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.4-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f68e049282059edc9beeb0a14fcfe372aa408033557177a3dcd815f1b1817eea
MD5 967b4596fccadb6ed5c17e9a41ea5b3d
BLAKE2b-256 eba759e53877593ec62c06228df79dfd3b37afed097f0e838245c3634294fbba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5606ad1c49b7dd67d68b6de8a33786f0728feb9f8b148e2708843d2e9fa4b166
MD5 b1e8d3757729d9db5ec579a8bf17e467
BLAKE2b-256 29e0e4f06413f4b727ddaa1f4615edeb08cbb722dd7ede76db4b854da0550c98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7eed0c50b2f315a16786bade3ce95393c167c43301faefe342ff1d7882c820fa
MD5 ec6d154fa4a5acc95e6bcb10be67bfd1
BLAKE2b-256 fbee00836429593e76bad3d13f60075ef2c46b1c0c1846e7946f2cd8d139b08b

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.4-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e5729885cbf446fe4db5a7d4837a5a974686281e6ee363d7eb1332e21ee37eb3
MD5 5a52514213230e99a77a9dc071c791f8
BLAKE2b-256 1ede6a166ffa6351a716e09f1fc55f4fa0735e56bfee324071812504a51030f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d722598945d3dfbe4d323c116003429ef87d90132770d88d033c5b06b1dd70cf
MD5 fb0868c95e013dcfe7531444642e251b
BLAKE2b-256 065631213f177a265e35b26daf32757064b9c342fac28603e948c5f62db433e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2bb2aece965203db6f093962c0bdcd95c7e1f892d6c438ac85d1c326453d6146
MD5 02e5df025a57ae80a4b1f74569a78f63
BLAKE2b-256 0dfcabaa908d684bd6ce9493df4f9ee3a87d6fd87228d8f539d270e2815c4f79

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.4-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8bf43ee5acf0fae09a69e858e8c3d7c71318723a503fed867915c19d2c6e9922
MD5 4399090b0f5c937f171ead71123b9e27
BLAKE2b-256 e0e15bb74b50247f47df3716229a668915c2e89be84ac20f1b330c523dbd09b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fbc73d3d2247350974588c9778b3e08b87d2a5fcf8ed516039fb3c5a6e92928f
MD5 838df9f60672cc1167cb762b3df9a6dc
BLAKE2b-256 bf7340d07fb30837ef9f6ef04aa614a7f910a520522b2fb84cf8d0c599d46715

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