Package: minvr3
Python MinVR3 libraryThis package provides communication bindings for MinVR3 in Python. This is
useful because the IV/LAB has historically used Python for many web server
applications (Flask or Django), and it's useful to communicate between Unity and
these servers in real-time.The implementation here is based off of the MinVR3.cpp~ client and server.Check the package out on PyPI:InstallationYou can install theminvr3Python package from the Python package index using the following command:python3 -m pip install --user minvr3Getting StartedThe Python MinVR3 client can function as a client or server. Look below for
simple examples of running a MinVR3 client and server. Check out theappsfolder for more complete examples.Both the server and client implementation are compatible with theTcpJsonVREventConnectionprovided by the MinVR3-UnityPackage. You can have a
Python server connect with a Unity client, and vice versa.Server codeCopy/paste the following code to set up a simple server that sends 10 integer VR Events and listens for 10 integer VR Events:importtimefromminvr3importminvr3_netHOST='127.0.0.1'PORT=9034listener=minvr3_net.create_listener(HOST,PORT,0)# wait for 1 connectionwhilenotminvr3_net.is_ready_to_read(listener):print('waiting for connection')time.sleep(1)client=minvr3_net.try_accept_connection(listener)ifclientisNone:print('no connection')exit(1)# test send/receive uint32forcountinrange(10,20):minvr3_net.send_uint32(client,count)print('sent',count)forcountinrange(0,10):c=minvr3_net.receive_uint32(client)print('got',c,'expected',count)minvr3_net.close_socket(client)Client codeCopy/paste the following code to set up a simple client that sends 10 integer VR Events and listens for 10 integer VR Events:fromminvr3importminvr3_netHOST='127.0.0.1'PORT=9034print('Connecting to server',HOST,PORT)server=minvr3_net.connect_to(HOST,PORT)# test send/receive uint32forcountinrange(10,20):c=minvr3_net.receive_uint32(server)print('got',c,'expected',count)forcountinrange(0,10):minvr3_net.send_uint32(server,count)print('sent',count)minvr3_net.close_socket(server)Relay serverIn addition to example code, a pure Python relay server is also supplied. This server receives VREvents from clients, and relays them to all other clients.To run the relay server, you can run:python3 -m minvr3.apps.relay_serverDevelopment Installation and Deploying a new packageInstalling the dev versionTo install theminvr3Python package locally, run the following command in this folder:python3 -m pip install --user --editable .If you're on Windows, probably need to replacepython3withpyin the above commands.Deploying the package to PyPITo do this, you will need an account onhttps://pypi.organdhttps://test.pypi.org.Once you've made your changes, build the package, then deploy it to the Python Package Index.First, make sure you have the build / deploy tools:py -m pip install --user --upgrade build
py -m pip install --user --upgrade twineBuild it (run in this folder):py -m buildTest deploy it (run in this folder):py -m twine upload --verbose --repository testpypi dist/*verify that it all looks good on the deployed test site:https://test.pypi.org/project/minvr3/Then, actually deploy it:py -m twine upload --verbose dist/*