Install python-venv: run sudo apt install python3.10-venv
(with the relevant python version), in order to be able to create a virtual environment.
cd python
cd into babushka/python folder
python -m venv .env
in order to create a new virtual env.
source .env/bin/activate
in order to enter virtual env.
pip install -r requirements.txt
install the library requriements (run in babushka/python folder)
maturin develop
to build rust code and create python wrapper.
maturin develop --release
to build rust code optimized for release and create python wrapper.
maturin develop --release --strip
to build optimized code without symbols, ready for release.
Autogenerate python's protobuf files with:
BABUSHKA_PATH=.
// e.g. /home/ubuntu/babushka
protoc -Iprotobuf=${BABUSHKA_PATH}/babushka-core/src/protobuf/ --python_out=${BABUSHKA_PATH}/python/python/pybushka ${BABUSHKA_PATH}/babushka-core/src/protobuf/*.proto
pip install -r dev_requirements.txt
install the library's development requriements (run in babushka/python folder)
Run pytest --asyncio-mode=auto
from this folder, or from the tests
folder. Make sure your shell uses your virtual environment.
Using VS code, install the following extensions:
Or, run in a terminal:
cd babushka/python
isort . --profile black --skip-glob python/pybushka/protobuf
black --target-version py36 . --exclude python/pybushka/protobuf
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=python/pybushka/protobuf,.env/* --extend-ignore=E230
flake8 . --count --exit-zero --max-complexity=12 --max-line-length=127 --statistics --exclude=python/pybushka/protobuf,.env/* --extend-ignore=E230
# generate protobuf type files
MYPY_PROTOC_PATH=`which protoc-gen-mypy`
protoc --plugin=protoc-gen-mypy=${MYPY_PROTOC_PATH} -Iprotobuf=../babushka-core/src/protobuf/ --python_out=$./python/pybushka --mypy_out=./python/pybushka ../babushka-core/src/protobuf/*.proto
# run type check
mypy .