Skip to main content

A simple, natively parallel WebSocket server module for Python built with Rust, tokio, and pyo3.

Project description

quicksocket

MIT licensed Actions Status PyPI Crates.io

A simple WebSocket server built in Rust using tokio, tokio-tungstenite, and pyo3. Supports Windows, macOS, and Linux. Still unstable!

pip install quicksocket

Check out example-usage/quicksocket_with_types.py for an example of a wrapper WebsocketServer class around the quicksocket API and also provides type annotations for e.g. autocompletion in your IDE.

Not stable, a bit verbose, and a bit messy!

The server listens for WebSocket connections on port 50808, and currently this is not configurable. (see src/server/tokio_server.rs).

quicksocket's code is originally designed for use with Ultraleap's Web Visualizer project, and as such is intended for a console python visualizer server and leverages plain println!s for logging purposes.

At some point in the future it'll make sense to switch to some proper env logging system. Pardon the mess :)

Building Locally

You'll need Rust and access to some python.exe of version 3.6 or greater.

You'll also need OpenSSL. See the Ubuntu section for installation details on Ubuntu. OpenSSL is slightly trickier for Windows. You can use Chocolatey or vcpkg, or download a binary distribution of OpenSSL. You may need to set $Env:OPENSSL_DIR (PowerShell syntax) to your installation directory for your Windows build session if using Chocolatey, or a binary install, or if vcpkg isn't activated for your session. macOS should have it by default.

Once Rust is installed:

cargo build --release

This will output an .so or a .pyd depending on your OS into the target/release directory.

To build a wheel for your python/OS combo:

pip install maturin
maturin build

There's CI for Windows, macOS, and Linux for Pythons 3.6 through 3.9. Check out the Actions tab for now (proper release tags coming "soon").

Targeting builds to specific Python versions

If you're targeting a specific python version, or if you don't have python on your PATH, you can set PYTHON_SYS_EXECUTABLE to the python executable in your machine with that version.

e.g., on Windows via Git Bash:

PYTHON_SYS_EXECUTABLE=/c/my/path/to/python.exe cargo build --release

Ubuntu

Make sure you have libssl and libpython installed:

sudo apt-get install libssl-dev
sudo apt-get install libpython3-dev

If you encounter errors building pyo3, you may need to check whether it can find your python and any related python dev dependencies: https://pyo3.rs/v0.10.1/building_and_distribution.html

Todos:

Little utility HTML via github pages

Could expose this through Github Pages so it's easy for a new user to test their server usage: https://github.com/nickjbenson/quicksocket/blob/main/archive/examples/wip01_basic_websocket_client.html

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

quicksocket-1.0.0-cp39-none-win_amd64.whl (417.0 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

quicksocket-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

quicksocket-1.0.0-cp39-cp39-macosx_10_7_x86_64.whl (559.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

quicksocket-1.0.0-cp38-none-win_amd64.whl (416.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

quicksocket-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

quicksocket-1.0.0-cp38-cp38-macosx_10_7_x86_64.whl (559.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

quicksocket-1.0.0-cp37-none-win_amd64.whl (416.7 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

quicksocket-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

quicksocket-1.0.0-cp37-cp37m-macosx_10_7_x86_64.whl (559.7 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

quicksocket-1.0.0-cp36-none-win_amd64.whl (416.3 kB view hashes)

Uploaded CPython 3.6 Windows x86-64

quicksocket-1.0.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

quicksocket-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl (558.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page