The CMSDK library packed as Python wheels for Linux, Windows and macOS

pip install cmsdk3: the full CMSDK library for Python 3.10 and later

CMSDK is the C++ library under Psyclone: the DataMessage format, the crank API, subscriptions, time and many utilities. Python has had a binding for it for a long time, called cmsdk3. Until now you got that binding from a Psyclone distribution, built for the one Python version the distribution was built with.

With 2.3.2, cmsdk3 is a normal package on PyPI:

pip install cmsdk3

One wheel per platform, every Python from 3.10 🎯

The binding is now built against the Python stable ABI (Py_LIMITED_API, baseline 3.10). One compiled wheel works with every later CPython, so each platform gets a single wheel tagged cp310-abi3. It installs on Python 3.10, 3.11, 3.12, 3.13, 3.14 and later releases, with no rebuild when you upgrade Python.

Platform Wheel
Linux x86_64 (glibc 2.28+: RHEL 8+, Debian 10+, Ubuntu 18.10+) cmsdk3-2.3.2-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Windows x64 cmsdk3-2.3.2-cp310-abi3-win_amd64.whl
macOS on Apple Silicon (arm64, macOS 11+) cmsdk3-2.3.2-cp310-abi3-macosx_11_0_arm64.whl

Each wheel was tested on Python 3.10, 3.11, 3.12, 3.13 and 3.14. A tool called abi3audit checks that the binding uses nothing outside the stable ABI.

Not covered yet: – Other platforms: Linux on ARM (aarch64), Alpine (musllinux), Intel Macs and Windows on ARM. On these, pip install cmsdk3 finds no wheel. You can build one from a Psyclone or CMSDK checkout with pip wheel CMSDK/python-wheel, which needs a C++ compiler and the OpenSSL 3 headers. – Free-threaded builds: the free-threaded Python builds (3.13t, 3.14t) are outside the stable ABI.

SSL included πŸ”’

The wheels are built with SSL/TLS, so https and wss work. Each wheel carries its own OpenSSL 3.5 (LTS), linked statically: – Linux: none of its symbols are exported, so Python’s own ssl module works next to it in the same process, whichever OpenSSL your Python uses. – Windows: the wheel brings the C++ runtime it needs. – macOS: the wheel links only the system libraries.

What you can do with it 🧰

cmsdk3 is the same binding that Python cranks use inside Psyclone. It has the DataMessage class with every entry type (strings, numbers, binary data, arrays, maps, attached messages), both wire forms, and JSON, XML and CSV output:

import cmsdk3

m = cmsdk3.DataMessage()
m.setString("PsyPost", "Reading")
m.setDouble("Value", 21.5)
m.setDataBytes("Raw", b"\x00\x01\x02")
print(m.toJSON())                                  # valid JSON

wire = m.getPackedBytes()                          # the packed form; m.getBytes() is the full form
back = cmsdk3.DataMessage.fromBytes(wire)          # reads either form
print(back.getDouble("Value"), back.getDataBytes("Raw"), list(back.getAllKeys()))
print(cmsdk3.PrintTimeString(cmsdk3.GetTimeNow()))

It also has the time functions, statistics helpers such as MovingAverage, the crank API (PsyAPI) and message playback. The bytes are the ones the C++ library writes, so a Python tool can read, write or check messages for any part of a Psyclone system.

A plain socket and cmsdk3 are enough to talk to a Psyclone UDP service:

import socket, cmsdk3

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
m = cmsdk3.DataMessage()
m.setString("PsyPost", "AudioFrame")
m.setString("PsyDevice", "phone-s25")
s.sendto(m.getBytes(), ("host", 18600))
r = cmsdk3.DataMessage.fromBytes(s.recvfrom(65536)[0])
print(r.getString("PsyTrigger"))

For anything beyond a quick test, use psyclone-client (below). It handles keepalives, reconnects and request/reply for you.

cmsdk3 or psyclone-client? πŸ€”

Both read and write the same bytes, and the psyclone-client test suite checks that they agree in both directions.

cmsdk3 is the full C++ library: native code, Python 3.10+, three platforms for now. – Use it when you need the whole CMSDK in Python: the crank API, every DataMessage feature, playback, and the time and statistics helpers. – Use it for tools and tests that work with Psyclone’s own data.

psyclone-client is a small, pure-Python library: no native code, Python 3.8+, every OS. – Use it for programs outside a system that talk to its services. – Use it to attach as a remote module (Psyclone 2.3.2). – It handles connections for you: keepalive, reconnects, packed-form negotiation and stats.

The two use similar method names: psyclone-client also accepts the camelCase names of cmsdk3 (setString, getInt, fromBytes, …). Code moves easily from one to the other.

And inside Psyclone 🐍

The same stable-ABI change applies to Python cranks. Since 2.3.2 a Psyclone binary distribution works with any installed CPython 3.10 or later: – Linux and macOS: Psyclone finds the installed Python when the first Python crank starts. You can choose one with PSYCLONE_PYTHON, PSYCLONE_PYTHONLIB or the module parameter pythonlib. – Windows: Psyclone links python3.dll.

On macOS you no longer need one particular Homebrew Python: Homebrew, python.org and uv all work.

Python cranks inside Psyclone load the cmsdk3 that ships in the distribution, next to the Psyclone binary.

How the wheels are built πŸ—οΈ

The wheels are built with cibuildwheel from CMSDK/python-wheel: – Linux: in a manylinux_2_28 container. – Windows: with Visual Studio 2022. – macOS: on Apple Silicon.

The recipe ships in the CMSDK BSD source distribution, including a ready GitHub Actions workflow. You can build wheels for your own platform from it.

Licence: Extended BSD (CADIA clause).

Read more

Published by CMLabs. Communicative Machines builds Psyclone AIOS, an open-source orchestration runtime for sub-millisecond, crash-resistant, self-reconfiguring AI systems.

Similar Posts

Leave a Reply