This is a lab project for an upcoming workshop on FFI
- cargo
- prost
- pyo3
- tokio
- tonic
- rustc
- python3.11
- pip: https://pip.pypa.io/en/stable/installation/
- grpcio
- grpcio-tools
- maturin
- protobuf
- protoc: https://github.com/hyperium/tonic#dependencies
TODO: Can we use Docker to handle this for the users?
From the project root:
- Create a virtualenv to work in:
python -m venv .venv
- Install the necessary python packages:
pip install --require-virtualenv -r requirements.txt
NOTE: vscode doesn't seem to handle virtualenvs very well. You can either skip making a virtualenv entirely (and the --require-virtualenv), add the new python path (located at .venv/Scripts/python(.exe)) to vscode (ctrl-shift-p -> Python: Select Interpreter), or use a different terminal for running the commands below.
There are 2 folders, workshop and solution. As the names imply, workshop will contain partially completed code to be completed during the workshop itself while solution holds a working final version of the code at the end of the workshop. There are 3 main binaries to run (in either the workshop or solution folder):
- cli.py: cli for executing some python code against a json database
- Usage:
python cli.py pymk 0
(see--help
for more)
- Usage:
- database_server.py: a "remote" database server implemented in python to replace the in-memory database
- Usage:
python database_server.py
- Usage:
- database_server: a "remote" database server implemented in rust to replace the in-memory database
- Usage:
cd database; cargo run --release
- Usage:
There is also an FFI library (the main point of the workshop) that needs to be built with cd database_ffi; maturin develop
. Then you should be able to run python -c import database_ffi