Skip to main content

Rugged Science SDK Python Bindings

Project description

Python SDK

This is a wrapper around the Rugged Science SDK with the only difference being that exceptions are automatically thrown. There are no getLastError or getLastErrorString functions.

Installing

The package can be installed either by compiling the sources or installing via python -m pip install rssdk.

Dio Example

from rssdk import RsDio, OutputMode

dio = RsDio()
try:
    dio.setXmlFile("ecs9000.xml")
except Exception as e:
    print(e)
    exit(1)

dio.setOutputMode(1, OutputMode.ModeNpn)

dio.digitalRead(1, 1)
dio.digitalWrite(1, 11, True)

PoE Example

from rssdk import RsPoe, PoeState

poe = RsPoe()
try:
    poe.setXmlFile("ecs9000.xml")
except Exception as e:
    print(e)
    exit(1)

poe.getPortState(3)
poe.setPortState(PoeState.StateDisabled)

Compiling

The Python bindings are built against the standard C++ SDK libraries using pybind11. There are two ways to compile them. Either using Python's build system or by using cmake directly. Both options assume you have have already cloned the repository as shown in the step below.

NOTE: It is best to enable long paths in Windows when compiling using the Python build system.

git clone https://github.com/ruggedscience/SDK
cd SDK

Python Build

Using Python's build system is the recommended way to build the bindings. It will produce a wheel that can be installed using pip and handles the installation of the required build modules. It will install all of the modules inside an isolated virtual environment that will be deleted after compilation is finished.

  1. Install the Python build module.

    python -m pip install build
    
  2. Build the source distribution and wheel.

    python -m build
    
  3. Install the newly built wheel.

    python -m pip install ./dist/<name of wheel file>.whl
    

Cmake build

The cmake build process isn't quite as straightforward but offers more flexibility. Since multiple dependencies are required it is suggested that you create a virtual environment for the build process to use. Note that the resulting package will be installed into that virtual environment. Information on how to do this can be found in the official Python docs.

  1. Install requirements

    python -m pip install pybind11 setuptools_scm mypy
    

    Note: mypy is optional and used to generate stub files. This allows IDEs to offer code completion.

  2. Create build folder

    mkdir build
    cd build
    
  3. Configure cmake

    cmake -DBUILD_PYTHON_BINDINGS=ON -DINSTALL_PYTHON_BINDINGS=ON -DBUILD_SHARED_LIBS=OFF -DINSTALL_XML=OFF -DINSTALL_UTILITIES=OFF -DINSTALL_SDK=OFF ..
    

    Note: On Linux the build type should be set to release using -DBUILD_TYPE=Release.

  4. Build and install

    cmake --build . --target install
    

    Note: On Windows the build type should be set to release using --config Release.

Project details


Download files

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

Source Distribution

rssdk-3.1.2.tar.gz (93.3 kB view hashes)

Uploaded Source

Built Distributions

rssdk-3.1.2-cp311-cp311-win_amd64.whl (141.9 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

rssdk-3.1.2-cp311-cp311-win32.whl (123.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

rssdk-3.1.2-cp311-cp311-musllinux_1_1_x86_64.whl (701.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

rssdk-3.1.2-cp311-cp311-musllinux_1_1_i686.whl (765.3 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

rssdk-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (182.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rssdk-3.1.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (191.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

rssdk-3.1.2-cp310-cp310-win_amd64.whl (141.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

rssdk-3.1.2-cp310-cp310-win32.whl (123.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

rssdk-3.1.2-cp310-cp310-musllinux_1_1_x86_64.whl (701.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

rssdk-3.1.2-cp310-cp310-musllinux_1_1_i686.whl (765.4 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

rssdk-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (182.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rssdk-3.1.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (191.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

rssdk-3.1.2-cp39-cp39-win_amd64.whl (138.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

rssdk-3.1.2-cp39-cp39-win32.whl (123.8 kB view hashes)

Uploaded CPython 3.9 Windows x86

rssdk-3.1.2-cp39-cp39-musllinux_1_1_x86_64.whl (701.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

rssdk-3.1.2-cp39-cp39-musllinux_1_1_i686.whl (766.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

rssdk-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (182.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rssdk-3.1.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (191.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

rssdk-3.1.2-cp38-cp38-win_amd64.whl (141.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

rssdk-3.1.2-cp38-cp38-win32.whl (123.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

rssdk-3.1.2-cp38-cp38-musllinux_1_1_x86_64.whl (701.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

rssdk-3.1.2-cp38-cp38-musllinux_1_1_i686.whl (765.9 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

rssdk-3.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (183.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rssdk-3.1.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (190.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

rssdk-3.1.2-cp37-cp37m-win_amd64.whl (141.5 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

rssdk-3.1.2-cp37-cp37m-win32.whl (124.9 kB view hashes)

Uploaded CPython 3.7m Windows x86

rssdk-3.1.2-cp37-cp37m-musllinux_1_1_x86_64.whl (700.9 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

rssdk-3.1.2-cp37-cp37m-musllinux_1_1_i686.whl (769.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

rssdk-3.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (182.9 kB view hashes)

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

rssdk-3.1.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (191.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

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