This directory contains Python example projects for MSCL.
- MSCL Python Library: You must have
MSCL.pyand the native module_MSCL.pyd(Windows) or_MSCL.so(Linux). - Python: A compatible Python version.
See the bindings instructions for more information on how to build the MSCL Python bindings.
Note: The version of Python used must match the version used to build the MSCL Python bindings.
To run the Python examples:
-
Locate MSCL: Find the
MSCL.pyand_MSCL.pyd/_MSCL.sofiles. -
Set PYTHONPATH: Add the directory containing these files to your
PYTHONPATHenvironment variable.$env:PYTHONPATH += ";C:/path/to/mscl/python/binding"
export PYTHONPATH=$PYTHONPATH:/path/to/mscl/python/binding
-
Run the Script:
python examples/python/wireless/main.py
Alternatively, you can copy MSCL.py and the native module into the same
directory as the example script or into your site-packages/dist-packages.
CMake can be used to set up a wrapper that automatically configures the
PYTHONPATH to run the examples against the built MSCL library. This only works
as part of the main MSCL project.
The following options need to be set:
MSCL_BUILD_PYTHON3: Required to build Python3 bindings (ON).MSCL_PYTHON3_REQUESTED_VERSION: Optional to override the Python3 version ("3.12").MSCL_BUILD_PYTHON2: Required to build Python2 bindings (ON).MSCL_PYTHON2_REQUESTED_VERSION: Optional to override the Python2 version ("2.7").MSCL_BUILD_PYTHON_EXAMPLES: Enable building the Python examples (ON).
cmake -S . -B build -DMSCL_BUILD_PYTHON3:BOOL=ON -DMSCL_BUILD_PYTHON_EXAMPLES:BOOL=ONcmake -S . -B build -DCMAKE_BUILD_TYPE:STRING=Release -DMSCL_BUILD_PYTHON3:BOOL=ON -DMSCL_BUILD_PYTHON_EXAMPLES:BOOL=ONBuild the Python example targets:
MSCL-Python3.12-Displacement-Example: The displacement example.MSCL-Python3.12-Inertial-Example: The inertial example.MSCL-Python3.12-Wireless-Example: The wireless example.
Note: Replace 3.12 with your Python version as needed
cmake --build build --config Release --target MSCL-Python3.12-Wireless-Example --parallel $env:NUMBER_OF_PROCESSORScmake --build build --target MSCL-Python3.12-Wireless-Example --parallel $(nproc)