Skip to content

fork of pyliblo with better pip integration, binary wheels and no external dependencies

License

Notifications You must be signed in to change notification settings

gesellkammer/pyliblo3

Repository files navigation

pyliblo3

This is a fork of the original bindings for liblo, making it pip installable.

The provided wheels include the liblo library and don't have any further dependencies, making it completely pip installable

Example

Simple blocking server

import pyliblo3 as liblo
server = liblo.Server(8080)

def test_handler(path, args, types, src):
    print(args)
    
server.add_method("/test", None, test_handler)

while True:
    server.recv(100)

Threaded server

from pyliblo3 import *
import time


class MyServer(ServerThread):
    def __init__(self, port=1234):
        ServerThread.__init__(self, port)

    @make_method('/foo', 'ifs')
    def foo_callback(self, path, args):
        i, f, s = args
        print(f"Received message '{path}' with arguments: {i=}, {f=}, {s=}")

    @make_method(None, None)
    def fallback(self, path, args):
        print(f"received unknown message '{path}' with {args=}")


server = MyServer()
server.start()
print(f"Server started in its own thread, send messages to {server.port}. Use CTRL-C to stop")

while True:
    send(("127.0.0.0", server.port), "/foo", 10, 1.5, "bar")
    send(("127.0.0.0", server.port), "/unknown", (3, 4))
    time.sleep(1)
    

Documentation

https://pyliblo3.readthedocs.io


Installation

pip install pyliblo3

Installation from source

When installing from source, liblo needs to be installed.

Linux

sudo apt install liblo-dev

git clone https:/gesellkammer/pyliblo3
cd pyliblo3
pip install .

MacOS

First install liblo

brew install liblo

Or, without using brew:

git clone https:/radarsat1/liblo
cd liblo
mkdir macosbuild && cd macosbuild
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" ../cmake
cmake --build . --config Release
sudo cmake --install .

Then install pyliblo3

git clone https:/gesellkammer/pyliblo3
cd pyliblo3
pip install .

Windows

git clone https:/radarsat1/liblo
cd liblo
New-Item -ItemType Directory -Force -Path "windowsbuild"
cd windowsbuild
cmake -A x64 -DCMAKE_GENERATOR_PLATFORM=x64 -DWITH_TESTS=OFF -DWITH_CPP_TESTS=OFF -DWITH_EXAMPLES=OFF -DWITH_TOOLS=OFF ../cmake
cmake --build . --config Release
cmake --install .
git clone https:/gesellkammer/pyliblo3
cd pyliblo3
pip install .

About

fork of pyliblo with better pip integration, binary wheels and no external dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published