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

Uploaded CPython 3.12Windows x86-64

pysimplicityhl-0.3.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pysimplicityhl-0.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

pysimplicityhl-0.3.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 43bfb7bf9fc7bb3d22ef836ac64b0d0135e96be15bcf55b1096745a8183755a4
MD5 81916a55b5eb9fca74c716ecc2beb49f
BLAKE2b-256 753c7e045e14da2bafee9c4a9bb62a77a7ecb8bb3b2b5c902494f1d89e0799de

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e22acdc2073c51cd47abb4d62b212443c9a1e5b3ac1ab68d72199266387dd2a
MD5 98b83143d946bded3d30980b0a25b411
BLAKE2b-256 386d853ec0a1cde99a583df1b210b7b58ab113c8a866537b834b989e76905827

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b7f1860d6389a8d5f729748d1d6c8a6d280098b5373b614ea02ae44f5fb51a3
MD5 ce9c9ee46ceba9060354ecdf1459daa8
BLAKE2b-256 86a7831414bfd4a25ca5e7e8d807252c5127e083e2e8599d361a6baa7be30e46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b0c3f9285dfd6d0ceb4d806cb5c5c127fa0a3c0109d53571875bed5515ce7070
MD5 f5c1326746fb3808ef4e1935f3fa6093
BLAKE2b-256 14a8ca0f63963ae0e28c9a9564f6ed269ba96bdc7c1c94f42f47bf124af7c1d7

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9ed395c5ace4e661a0eb7793ec21b8b03a6335b74a8c2660e231640736a96ae
MD5 11a04be4e957739bcc96ec53991b1232
BLAKE2b-256 955bf2c42e910a3f59f6f4842402e1ad594ec294a320ba7b7767c14660b43ef6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a930d5482da0d9f71672058975a1ed44946cdd7b78dc628f530cf4abe4b0c269
MD5 417a23ba98550589e594d7f489b69422
BLAKE2b-256 75178d02956289b5f405ddda948d387cb1017f31c405bdce9147609f1f946a57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0f5ce1fed94d8263d39a9e1ee0947b2ec1ac8739191ae7f342006cb40698c3c0
MD5 c23db71c08a63f36a3db5bafaf4d9a8b
BLAKE2b-256 c36d770e0b6a936d6beef968870bd5882d9c556f6ad9382b695db44b910f7c98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb833b2069f94beac372f85269365dc580659dbb5ff689fa8cbe565d8242d296
MD5 73144c99cffa0f47dc50cc7e30552476
BLAKE2b-256 0e1807645c9836b4e634acfd7efdd1adf67936c844840b97dc16f332925dcdd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cbbd5676a726c9e9e04551be53f023b28867312135ed65dfe88b2fdb43a398cc
MD5 a074bd30a589a6be882fe5d16f7e0914
BLAKE2b-256 7e702fdf506a92631d4237a288dacfebcd9da16ced3bf93139f8e1afa0332d6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2de5a0b30024b04915e48e849a02cb925575a6a577d918558a56443f8ab69aae
MD5 f4d700100baf803e911e3d3b97566db7
BLAKE2b-256 98ebcf2b1acdd571db9b9dbe02418b6e966c5d52a597e4c17f88c2bef84651be

See more details on using hashes here.

File details

Details for the file pysimplicityhl-0.3.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 65b0b7a708f8b8c00edca90d7780b95dec468360be9e7300cfcfcd54349a0a3c
MD5 8d05f374926986c2dfeea1451ae5cfe1
BLAKE2b-256 4631d641b53f2f419050a704a1b2966f4b8b30cebe1e0cd47ed638c4d09997f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysimplicityhl-0.3.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcc22eebcb49099ca3b845fe94f2f8425dee3f6ef70f32ef09fa077d19fad10e
MD5 e95608b40fa7215a8d5301bbaf1e34bc
BLAKE2b-256 407ec8ef614e3b60c43d2f79f9c2a584ebd6b228c8ba15e380a3eafcfbc852a8

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