Giter Site home page Giter Site logo

nxsaken / iroha-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hyperledger/iroha-python

0.0 0.0 0.0 1.16 MB

Python library for Hyperledger Iroha, a simple distributed ledger.

Home Page: https://wiki.hyperledger.org/display/iroha

License: Apache License 2.0

Python 23.51% Rust 76.49%

iroha-python's Introduction

Iroha python

Python library for Hyperledger Iroha 2.

Install

You should install rust (cargo) and python.

pip install maturin
maturin build

After the build, you'll a name of the generated package "wheel" in the log, similar to this one:

๐Ÿ“ฆ Built wheel for CPython 3.10 to โ€ฆ/iroha-python/target/wheels/iroha_python-0.1.0-cp310-cp310-linux_x86_64.whl

Remember the version, change the directory and install the package:

cd target/wheels
pip install iroha_python-VERSION-linux_x86_64.whl
cd ~

After an installation, do a small test to check the installation was successful.

Normally, this test will display the library's contents:

python3 -c "import iroha2; print(dir(iroha2))"
['ClassPath', 'Client', 'Dict', 'Enum', 'KeyPair', 'List', 'Struct', 'Tuple', '_Client', '_Instruction', '_Query', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'data_model', 'get_class', 'import_module', 'iroha2', 'query', 'sys', 'to_rust']

If there was no error, you should be able to use iroha2-python library.

You may also see an error that ends like this:

ModuleNotFoundError: No module named 'iroha2.iroha2'

If it appears, your current directory may be the same as the directory with iroha2 and Python may be attempting to import it instead of the module. Switch to another directory and repeat the test.

Architecture

Stack

Architecturally python library uses rust client library. It is done via wrapping classes using rust library pyo3.

The data model of iroha itself is expected to be just classes without some special methods (without sidechannels, like doing http request). Communication channel for rust python methods using rust data model is achieved using pythonize rust library. It allows to represent almost all rust structures using python objects (via serde serialization).

Project layout

Python library

Python library right now is in iroha_python/iroha2. This directory has some directories:

  • iroha2 -- iroha2 library itself. Contains client and key generation at root
  • iroha2.crypto -- iroha crypto bindings
  • iroha2.data_model -- data model with all instructions, queries and expressions
  • iroha2.sys -- raw bindings to rust structures wrapped around python objects

Rust code

Generating python sys sources

There is a need to regenerate sys sources and update client library after major rust updates in data model.

cargo run -p generate -- iroha2/sys
yapf --style pep8 -r -i iroha2 example

iroha-python's People

Contributors

6r1d avatar alexstroke avatar appetrosyan avatar bastos525 avatar dependabot[bot] avatar i1i1 avatar quentini avatar ryjones avatar s8sato avatar samhsmith avatar takemiyamakoto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.