mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
sdk-py: Wheel build guide, and dev guide.
This commit is contained in:
@@ -1,33 +1,10 @@
|
||||
.POSIX:
|
||||
|
||||
# Pip install command
|
||||
PIP = pip install
|
||||
|
||||
# Maturin binary
|
||||
MATURIN = maturin
|
||||
|
||||
# Python dependencies
|
||||
DEPS = $(MATURIN) patchelf
|
||||
|
||||
# WARNING:
|
||||
# After all development here
|
||||
# we need to remove the venv folder,
|
||||
# as it breaks rest make operations
|
||||
# in the repo, so just run `make clean`.
|
||||
VENV = venv
|
||||
|
||||
# Venv setup
|
||||
VENV_SETUP = python3 -m $(VENV) $(VENV)
|
||||
|
||||
all:
|
||||
$(MATURIN) develop --release
|
||||
$(MATURIN) build --release
|
||||
@echo "You can install this wheel with pip install"
|
||||
|
||||
bootstrap: clean
|
||||
$(VENV_SETUP)
|
||||
. $(VENV)/bin/activate
|
||||
$(PIP) $(DEPS)
|
||||
|
||||
clean:
|
||||
rm -rf $(VENV)
|
||||
|
||||
.PHONY: all bootstrap clean
|
||||
.PHONY: all
|
||||
|
||||
@@ -1,40 +1,34 @@
|
||||
# darkfi-sdk-py
|
||||
|
||||
## Bootstrap
|
||||
Python bindings for some parts of the `darkfi-sdk` and the `zkvm`.
|
||||
|
||||
This python sdk requires a virtual environment, along with a build tool.
|
||||
To create the environment, execute:
|
||||
```
|
||||
$ make bootstrap
|
||||
```
|
||||
You may find more information in [pyo3](https://pyo3.rs/v0.15.1/#using-rust-from-python)
|
||||
setup guide.
|
||||
## Build and install
|
||||
|
||||
1. Install `maturin` via your package manager or from whatever source.
|
||||
2. Run `make` to build the wheel
|
||||
3. (Optional) Run pip install --user <path_to_wheel>
|
||||
|
||||
## Development
|
||||
|
||||
### Build
|
||||
For a development version you can use a venv:
|
||||
|
||||
After successfully bootstrapping the virtual environment,
|
||||
you can build the sdk by simply executing:
|
||||
```
|
||||
$ make
|
||||
$ python3 -m venv venv
|
||||
$ source venv/bin/activate
|
||||
(venv) $ maturin develop --release
|
||||
```
|
||||
|
||||
After all development is finished, you need to remove
|
||||
the virtual envirnment folder, as it breaks rest make
|
||||
operations in the repo, so just execute:
|
||||
```
|
||||
$ make clean
|
||||
```
|
||||
|
||||
### Usage example
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ python3
|
||||
from darkfi_sdk_py.base import Base
|
||||
a = Base.from_u64(42)
|
||||
b = Base.from_u64(69)
|
||||
a + b == Base.from_u64(111)
|
||||
>>> import darkfi_sdk_py
|
||||
>>> darkfi_sdk_py.__dir__()
|
||||
>>>
|
||||
>>> from darkfi_sdk_py.base import Base
|
||||
>>> a = Base.from_u64(42)
|
||||
>>> b = Base.from_u64(69)
|
||||
>>> a + b == Base.from_u64(111)
|
||||
```
|
||||
|
||||
### Randomness
|
||||
|
||||
Reference in New Issue
Block a user