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

Uploaded CPython 3.12Windows x86-64

pysimplicityhl-0.3.9-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.9-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pysimplicityhl-0.3.9-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.9-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 27b200a8a83be0f8f63c04168592d78762a8ccf2bc0d40c382b319efbaf61772
MD5 92533d916c5607328c2a0e29eb73ee9c
BLAKE2b-256 636407c2d9064a48296e793b08833f67e28fd4893cf2c8d985bc458ead6eb2f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 51f2ee0a85dbd8aa39c128a23fd5feef4b08698952a6d5cc7307ce2bf52f87c4
MD5 6c0b46da78d7eda207f1531a0a05ffed
BLAKE2b-256 f7265d79522f4523d43dc9701f7380eefb384bdc05e57818e2711025c038004a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bdacf8a52b53a8dcdde89f452af19e56b628db3474663c532846b294343d7e7
MD5 c35a9e78c12860e786c95d2589fa0f59
BLAKE2b-256 2239408ba0ee13469afc82a604dd808c54e8c648ef77765240cd3d59821c6602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d4d2a850f65860fadb50bbca971c3cc643e1686b8bf4173bad3994128502da2e
MD5 bc6209d5ae8d3dbd232b460e23cd5965
BLAKE2b-256 4cfa6ba1b2a6774faadef8c1b1b42babc8c965ff39e5c85769f27ec11aa04416

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 759e6a958cd6491332230da6c909e843ec1b383eed8e1744a381c3ea105a4215
MD5 e23984bd7e02cb5eda884dc1443e2cde
BLAKE2b-256 b835b3a0f0dd213ab9f5d0d0dc7b0b45665d1bab630282438a3ae38a5da65b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44a2b1e663caa36dc6c0f1641c1aab504f11014e97669ee99be2c3fd0c4d815f
MD5 8a178f35622583576803af411ec518f9
BLAKE2b-256 7b4224869b539c265aee56653535a463e5ae66ee348b84d1da249cd8caec2b53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e77df94b28cc766e55bf283992685f357563d68fd743849b7d70028c7c171bc4
MD5 a36279b427c0b609e59db6dff6c74ea8
BLAKE2b-256 c1abf6f0d23778908d2db6321291ccfa6bd9774205bf9175c1803a8079b875ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dc07b3df2b2b4e6645f27adf333ffd4d4ec961cb96f2492b0975c4d37c0de11b
MD5 f0c9b35b5ea30c95671679f5994c1fcd
BLAKE2b-256 3e775d76509ddd9faf283daaa7d7aa912e1239f34acb1e4758db24c33ae31148

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d54fff0f92e3d8bc5db8ad86ee6e8337da283d055edc21d072e2a05ef7284efe
MD5 ba297d4f14925984f97424c19f1944cd
BLAKE2b-256 f33ded6a3b13db79cd2a8c1b6e9d1a70c0cb4a9b792819cd45edb9fab33260b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d3394370af7de3b5f8669c1ad9a7f061a740cea80eb7dbbf97822097b96fe4e1
MD5 06e30967ef363ac98fd2390e47c1fbc3
BLAKE2b-256 febdde49cb7870c030b9c5bc3845b7e2c204ffbbc4edb99056bde9bcf2881d30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ab820aa80432db14700f8cf06fbe63ff7300225bc570c117369613c2fe8cf591
MD5 7eed09cb83e55264d06f8723956cb697
BLAKE2b-256 341e08f5b43ea63482de149d7a131e54b45dcf1583f1e27935afcbec3b0ebcd3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.9-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 566fbcf2abaaacb51ef15f0dccec556d20b7dab30f3897be4e44cb0f8191a72a
MD5 b3dc44b9ae4a7c00f8006c55fd34b0b2
BLAKE2b-256 d58ed2f890e54cdde5dbcad3eb7c8d9f2d0f27bd62345e1aee5558825db2b6fa

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