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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3886b29d91fd3e3237fd834906b00d00847e55df6875010596845844db0feb79
MD5 3740cb0013f48f6b3c6b0ad69e8b9bbf
BLAKE2b-256 888cc7ce7ec133daaf742e56625224b6bd17cf2437b7cb3b6eca6e7243a3d997

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ea1596707c2e063b0c4155b328af818d2035655a9a43b93b585d3b9475134171
MD5 bb155449edbf6b1bae0a954c813f920d
BLAKE2b-256 21c1745d2a28db86ddce6e7e2629ed4c939874d195fd3554f69e1662e1abba36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f20694420df4976cc1cccb5f8b19ccb0c679cb04086467b8988116886782d148
MD5 849f8639b8eb65662b1e5f601add1507
BLAKE2b-256 b0c5515c8c7f3d9610dc871be3ce13fe1e488f9a45beae8071de20e07b29c546

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 675cfb02294384695682579105f65e666c9b6c9af6956ff02697b6e36e30782d
MD5 985397f812260339e30dbf3ca829e2de
BLAKE2b-256 f61215488f748e6d8b9332169cc33ddf579d451fdfa25b0d0c56f4aa540d2a31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f154513a05ccce71a13bdab7877563e27b5c9e87cc1177d3b113177cd38250d7
MD5 b6bff5c394153957cf63bced02c95608
BLAKE2b-256 8a15307c1401130fc4019f11894eeeed27a274df02df025ef02077d67b511c43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7f641d9a0a371bb1c1c4af5dc35b4679e1e61b92662616ee3d3a28038ed45873
MD5 481ab733804973242bcbf895cd6bacdf
BLAKE2b-256 af5ec53bfcdf8b82fae35ab5bbb490ba55a332432a43bd3f8efde10ce360bdfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 783892f1e43da3c1417fe6d21758d73f5adce4b1b42ba91e4e008bf79f86b6cb
MD5 542c0f2a0edc57ef44ff8abe4386ad56
BLAKE2b-256 8292953024d0fac74dd45b0ea5462280d9a2b8e4b57692ba12c8d41657eba235

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 de4744c32cf3d4263e3c5ca7e61e91c618aefd56c49bb6c5520467b47c55e709
MD5 9b5c9d46c11f7b98faf3bcbd4fd9e3f1
BLAKE2b-256 0cba1eeda27ae8771a412be7e7a42a49c7c849f66b944aa853fdbd9a489b83fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e139abc94ff16e38ae5ad0d0a920f4445df1edcdfb4bbb31039e365fae4894c5
MD5 26f6a69eae5bd2564cd5e43890a76cce
BLAKE2b-256 1f1ebf755f1d5651e1781bccc38e79a4b6c46fee66cf3857a491449b34e87d91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48fc3a7d1d87c41837ab0796d891c6fdc19246ae351344e39a41159e0edd274c
MD5 27a99964f84d297316756dd9e6f52f4a
BLAKE2b-256 c5572e837e8107324bc029765b389e05ae1e6cedf6419c5c64cd5c07a70ddafc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 aa90203ceef406250892f92d665c92c08410a0c9bbb2fe89dd64f994856ac247
MD5 831de4292ea660c80234a86064b368ac
BLAKE2b-256 4da27c5a6d67060ed3cef2549263c0cbffb9cd13c2199b4c315101d43c036cde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e133a9d01c4da2a53c48b7aee297d637e4e51a7a635f1481845ac3248b0bd4d1
MD5 968fcca39bf1b00183349c5e6beaeb93
BLAKE2b-256 a9cf946aacc11cf44639e69b1571e06dea9257ef87ef3b227c28e85be5bb56d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e6ac8018014506ff7173455cae8e861c48d75cc63de039eaef860328ddba4eb
MD5 5e321ab02edb17f1ac765b2c46303efd
BLAKE2b-256 3f2d91e9cd282108e9141ad44ffcb442fcc1a35e2dd7eed56bf1c682000f5a22

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