1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
# 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
```python
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
```python
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
```bash
pip install pyliblo3
```
## Installation from source
When installing from source, ``liblo`` needs to be installed.
#### Linux
```bash
sudo apt install liblo-dev
git clone https://github.com/gesellkammer/pyliblo3
cd pyliblo3
pip install .
```
#### MacOS
First install liblo
```bash
brew install liblo
```
Or, without using brew:
```bash
git clone https://github.com/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
```bash
git clone https://github.com/gesellkammer/pyliblo3
cd pyliblo3
pip install .
```
#### Windows
```bash
git clone https://github.com/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 .
```
```bash
git clone https://github.com/gesellkammer/pyliblo3
cd pyliblo3
pip install .
```
|