pybinaryen


Namepybinaryen JSON
Version 1.116 PyPI version JSON
download
home_pagehttps://github.com/irmen/binaryen-interfaces/tree/master/pybinaryen
Summarypython bindings for the binaryen webassembly library
upload_time2024-02-21 12:44:33
maintainer
docs_urlNone
authorIrmen de Jong
requires_python
licenseMIT
keywords webassembly
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Latest Version](https://img.shields.io/pypi/v/pybinaryen.svg)](https://pypi.python.org/pypi/pybinaryen/)


# Python interface to the Binaryen library

This module provides a Python interface to the
[binaryen](https://github.com/WebAssembly/binaryen) webassembly library.

That library has to be installed separately, make sure it is available on your system as a shared library.
You may need to add something to your link library search path to let python pick it up.

*Requires Python 3.6 or newer.  Also works on pypy3 (because it uses cffi).*
*The minor version number of this library tracks the binaryen release number (such as 112)*

Software license: MIT

## Installation

This Python package expects binaryen to be installed in `/usr/include/` and `/usr/lib/`. On some Linux distributions community packages are available which install Binaryen in the correct place, have a search first to see if that's available for your distribution.

For distributions that don't have this, you [build from source](https://github.com/WebAssembly/binaryen) or download a release from https://github.com/WebAssembly/binaryen/releases and install it manually.

### Manual Installation

Manual installation can be done by extracting the archive, and copying (or symlinking) the files in it to the appropriate location in `/usr/`.

As an example here is what this might look like in GitHub Actions CI (for Ubuntu 22.04):

```yaml
    - name: Install Binaryen
      run: |
        wget https://github.com/WebAssembly/binaryen/releases/download/version_109/binaryen-version_109-x86_64-linux.tar.gz
        tar -xf binaryen-version_109-x86_64-linux.tar.gz
        sudo ln -s $PWD/binaryen-version_109/include/binaryen-c.h /usr/include/binaryen-c.h
        sudo ln -s $PWD/binaryen-version_109/include/wasm-delegations.def /usr/include/wasm-delegations.def
        sudo ln -s $PWD/binaryen-version_109/lib/libbinaryen.a /usr/lib/libbinaryen.a
```

## Example

Running the following code:
```python
import binaryen

module = binaryen.ModuleCreate()
params = binaryen.TypeCreate([binaryen.TypeInt32(), binaryen.TypeInt32()], 2)
results = binaryen.TypeInt32()
x = binaryen.LocalGet(module, 0, binaryen.TypeInt32())
y = binaryen.LocalGet(module, 1, binaryen.TypeInt32())
add = binaryen.Binary(module, binaryen.AddInt32(), x, y)
adder = binaryen.AddFunction(module, b"adder", params, results, binaryen.ffi.NULL, 0, add)
binaryen.ModulePrint(module)
binaryen.ModuleDispose(module)
```

results in the following Webasm Text output:
```
(module
 (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
 (func $adder (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
  (i32.add
   (local.get $0)
   (local.get $1)
  )
 )
)
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/irmen/binaryen-interfaces/tree/master/pybinaryen",
    "name": "pybinaryen",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "webassembly",
    "author": "Irmen de Jong",
    "author_email": "irmen@razorvine.net",
    "download_url": "https://files.pythonhosted.org/packages/06/f1/ad19b8333dc4f5dfbe74fd25d807466c1ddd217ed05a0c98cb36db4befb7/pybinaryen-1.116.tar.gz",
    "platform": null,
    "description": "[![Latest Version](https://img.shields.io/pypi/v/pybinaryen.svg)](https://pypi.python.org/pypi/pybinaryen/)\n\n\n# Python interface to the Binaryen library\n\nThis module provides a Python interface to the\n[binaryen](https://github.com/WebAssembly/binaryen) webassembly library.\n\nThat library has to be installed separately, make sure it is available on your system as a shared library.\nYou may need to add something to your link library search path to let python pick it up.\n\n*Requires Python 3.6 or newer.  Also works on pypy3 (because it uses cffi).*\n*The minor version number of this library tracks the binaryen release number (such as 112)*\n\nSoftware license: MIT\n\n## Installation\n\nThis Python package expects binaryen to be installed in `/usr/include/` and `/usr/lib/`. On some Linux distributions community packages are available which install Binaryen in the correct place, have a search first to see if that's available for your distribution.\n\nFor distributions that don't have this, you [build from source](https://github.com/WebAssembly/binaryen) or download a release from https://github.com/WebAssembly/binaryen/releases and install it manually.\n\n### Manual Installation\n\nManual installation can be done by extracting the archive, and copying (or symlinking) the files in it to the appropriate location in `/usr/`.\n\nAs an example here is what this might look like in GitHub Actions CI (for Ubuntu 22.04):\n\n```yaml\n    - name: Install Binaryen\n      run: |\n        wget https://github.com/WebAssembly/binaryen/releases/download/version_109/binaryen-version_109-x86_64-linux.tar.gz\n        tar -xf binaryen-version_109-x86_64-linux.tar.gz\n        sudo ln -s $PWD/binaryen-version_109/include/binaryen-c.h /usr/include/binaryen-c.h\n        sudo ln -s $PWD/binaryen-version_109/include/wasm-delegations.def /usr/include/wasm-delegations.def\n        sudo ln -s $PWD/binaryen-version_109/lib/libbinaryen.a /usr/lib/libbinaryen.a\n```\n\n## Example\n\nRunning the following code:\n```python\nimport binaryen\n\nmodule = binaryen.ModuleCreate()\nparams = binaryen.TypeCreate([binaryen.TypeInt32(), binaryen.TypeInt32()], 2)\nresults = binaryen.TypeInt32()\nx = binaryen.LocalGet(module, 0, binaryen.TypeInt32())\ny = binaryen.LocalGet(module, 1, binaryen.TypeInt32())\nadd = binaryen.Binary(module, binaryen.AddInt32(), x, y)\nadder = binaryen.AddFunction(module, b\"adder\", params, results, binaryen.ffi.NULL, 0, add)\nbinaryen.ModulePrint(module)\nbinaryen.ModuleDispose(module)\n```\n\nresults in the following Webasm Text output:\n```\n(module\n (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))\n (func $adder (; 0 ;) (param $0 i32) (param $1 i32) (result i32)\n  (i32.add\n   (local.get $0)\n   (local.get $1)\n  )\n )\n)\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "python bindings for the binaryen webassembly library",
    "version": "1.116",
    "project_urls": {
        "Homepage": "https://github.com/irmen/binaryen-interfaces/tree/master/pybinaryen"
    },
    "split_keywords": [
        "webassembly"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06f1ad19b8333dc4f5dfbe74fd25d807466c1ddd217ed05a0c98cb36db4befb7",
                "md5": "181edce26cec65d18d0df26dc455bc4c",
                "sha256": "d431aa33191281ee088da30c2fe6cda36402fce1479be4537a142d7845a3e470"
            },
            "downloads": -1,
            "filename": "pybinaryen-1.116.tar.gz",
            "has_sig": false,
            "md5_digest": "181edce26cec65d18d0df26dc455bc4c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17106,
            "upload_time": "2024-02-21T12:44:33",
            "upload_time_iso_8601": "2024-02-21T12:44:33.594436Z",
            "url": "https://files.pythonhosted.org/packages/06/f1/ad19b8333dc4f5dfbe74fd25d807466c1ddd217ed05a0c98cb36db4befb7/pybinaryen-1.116.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-21 12:44:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "irmen",
    "github_project": "binaryen-interfaces",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pybinaryen"
}
        
Elapsed time: 0.21422s