Преглед изворни кода

sdk-py: Makefile added and README updated

aggstam пре 3 година
родитељ
комит
cc09d133c7
2 измењених фајлова са 59 додато и 7 уклоњено
  1. 33 0
      src/sdk/python/Makefile
  2. 26 7
      src/sdk/python/README.md

+ 33 - 0
src/sdk/python/Makefile

@@ -0,0 +1,33 @@
+.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
+
+bootstrap: clean
+	$(VENV_SETUP)	
+	. $(VENV)/bin/activate
+	$(PIP) $(DEPS)
+
+clean:
+	rm -rf $(VENV)
+
+.PHONY: all bootstrap clean

+ 26 - 7
src/sdk/python/README.md

@@ -1,15 +1,34 @@
-# Installation
+# darkfi-sdk-py
 
-Follow virtualenv and pyo3 setup guide: https://pyo3.rs/v0.15.1/#using-rust-from-python
+## Bootstrap
 
-## tldr
+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.
+
+## Development
+
+### Build
 
+After successfully bootstrapping the virtual environment,
+you can build the sdk by simply executing:
 ```
-$ python3 -m venv venv
-$ source venv/bin/activate
-$ maturin develop --release
+$ make
 ```
 
+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
+
 ```
 $ python3
 from darkfi_sdk_py.base import Base
@@ -18,7 +37,7 @@ b = Base.from_u64(69)
 a + b == Base.from_u64(111)
 ```
 
-## Randomness
+### Randomness
 
 Note that the `random` methods take randomness 
 from the OS on the Rust side.