Skip to main content

bindings for lausek's own virtual machine.

Project description


Create your own programming language in Python on top of lovm2.

pip3 install pylovm2


from pylovm2 import Expr, ModuleBuilder, Vm

# initialize a new module
module = ModuleBuilder()

# add the main entry point
main_hir = module.entry()
main_hir.assign('n', 2)
# call the module local function `add` with the value of `n`'print', 'got result:','add', Expr.var('n'), 1), '\n')'print', 'got result from pyfn:','pyadd', Expr.var('n'), 1), '\n')

# add new entry with arguments `a` and `b`
add_hir = module.add('add', ['a', 'b'])
add_hir.ret(Expr.add(Expr.var('a'), Expr.var('b')))

# add a python function to the module
module.add_pyfn('pyadd', lambda a, b: a.to_py() + b.to_py())

# build the module and print it
module =

# create vm, load and run module
vm = Vm.with_std()

Building and Publishing

NOTE: manylinux wheels are required for distribution

# just build the python package in release mode
# compiled wheels will be available inside ./target/wheels

# attempt publishing package on as well
./ release

Problems with SSL

manylinux wheels are not allowed to link to TLS libraries dynamically. Building without SSL support can be done like this:

maturin build --cargo-extra-args="--no-default-features --features lovm2/stdlib,lovm2/stdlib-net"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pylovm2, version 0.4.9
Filename, size File type Python version Upload date Hashes
Filename, size pylovm2-0.4.9-cp36-cp36m-manylinux2010_x86_64.whl (2.4 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pylovm2-0.4.9-cp37-cp37m-manylinux2010_x86_64.whl (2.4 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pylovm2-0.4.9-cp38-cp38-manylinux2010_x86_64.whl (2.4 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pylovm2-0.4.9-cp39-cp39-manylinux2010_x86_64.whl (2.4 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pylovm2-0.4.9.tar.gz (5.0 MB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page