|
1 |
| -# Iroha python |
| 1 | +# Iroha Python |
2 | 2 |
|
3 |
| -Python library for Hyperledger Iroha 2. |
| 3 | +Python library for **Hyperledger Iroha 2**. |
4 | 4 |
|
5 |
| -## Version |
| 5 | +This README provides essential information on how to install, build, and test the library, as well as useful references for deeper exploration. |
6 | 6 |
|
7 |
| -If you are using the latest iroha release, iroha2 MVP, then you should use the `main` branch. If you are using rc20 then you should use the 'stable' branch. |
| 7 | +## Table of Contents |
| 8 | +1. [Description](#description) |
| 9 | +2. [Library Version](#library-version) |
| 10 | +3. [Environment Requirements](#environment-requirements) |
| 11 | +4. [Installation and Build](#installation-and-build) |
| 12 | +5. [Verification of Installation](#verification-of-installation) |
| 13 | +6. [Running Tests](#running-tests) |
| 14 | +7. [Additional Resources](#additional-resources) |
8 | 15 |
|
9 |
| -## Install |
| 16 | +## Description |
10 | 17 |
|
11 |
| -To build, use the nightly-2024-09-09 version of the rust toolchain. Set it as the default before executing the build steps. TODO, complete list of dependencies. |
| 18 | +This library offers a Python interface for **Hyperledger Iroha 2**, providing classes and methods needed to integrate Iroha functionality into your Python projects. It covers core entities such as `Account`, `Asset`, `Domain`, `Transaction`, and many others. |
12 | 19 |
|
13 |
| -```sh |
14 |
| -maturin build |
15 |
| -pip install --break-system-packages target/wheels/iroha-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl |
16 |
| -``` |
| 20 | +## Library Version |
17 | 21 |
|
18 |
| -The exact path to the .whl file may vary. After an installation, do a small test to check the installation was successful. Normally, this test will display the library's contents: |
| 22 | +- If you are using the **latest Iroha release** (iroha2 MVP), please use the `main` branch. |
| 23 | +- If you are using **rc20**, switch to the `stable` branch. |
19 | 24 |
|
20 |
| -``` |
| 25 | +## Environment Requirements |
| 26 | + |
| 27 | +- **Rust** toolchain pinned to `nightly-2024-09-09` (necessary for building the library). |
| 28 | +- **Python 3.12** (based on the provided wheel file). |
| 29 | +- **Poetry** (for running tests) and any other dependencies required by `maturin` for building. |
| 30 | +- A functional local instance of **Hyperledger Iroha 2** for integration and testing purposes. |
| 31 | + |
| 32 | +## Installation and Build |
| 33 | + |
| 34 | +1. **Set the Rust toolchain** to the required nightly version: |
| 35 | + ```sh |
| 36 | + rustup override set nightly-2024-09-09 |
| 37 | + ``` |
| 38 | + |
| 39 | +2. **Build** the library with `maturin`: |
| 40 | + ```sh |
| 41 | + maturin build |
| 42 | + ``` |
| 43 | + This command generates a `.whl` file in the `target/wheels/` directory. |
| 44 | + |
| 45 | +3. **Install** the generated package: |
| 46 | + ```sh |
| 47 | + pip install --break-system-packages target/wheels/iroha-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl |
| 48 | + ``` |
| 49 | + The exact filename may differ depending on your system and Python version. |
| 50 | + |
| 51 | +## Verification of Installation |
| 52 | + |
| 53 | +To verify successful installation: |
| 54 | +```sh |
21 | 55 | python -c "import iroha; print(dir(iroha))"
|
| 56 | +``` |
| 57 | +If the library is correctly installed, you should see output similar to: |
| 58 | +``` |
22 | 59 | ['Account', 'AccountId', 'Asset', 'AssetDefinition', 'AssetDefinitionId', 'AssetId', 'AssetType', 'BlockHeader', 'Client', 'DomainId', 'Instruction', 'KeyPair', 'Mintable', 'NewAccount', 'NewAssetDefinition', 'PrivateKey', 'PublicKey', 'Role', 'SignedTransaction', 'TransactionQueryOutput', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'hash', 'iroha']
|
23 | 60 | ```
|
24 |
| - |
25 |
| -If there was no error, you should be able to use iroha-python library. |
26 |
| -You may also see an error that ends like this: |
27 |
| - |
| 61 | +If you encounter an error like: |
28 | 62 | ```
|
29 | 63 | ModuleNotFoundError: No module named 'iroha'
|
30 | 64 | ```
|
| 65 | +it means the installation did not succeed correctly, and Python cannot locate the package. Double-check that you installed the wheel in the same Python environment where you’re running the command. |
31 | 66 |
|
32 |
| -This means that the pip install did not work properly. |
| 67 | +## Running Tests |
33 | 68 |
|
34 |
| -## Running the tests |
| 69 | +1. In the main Iroha repository, set up the local test environment: |
| 70 | + ```sh |
| 71 | + scripts/test_env.py setup |
| 72 | + ``` |
| 73 | + This prepares a local Iroha test network. |
35 | 74 |
|
36 |
| -Running the tests requires you to have a running local test network of iroha. In the main iroha repository you must run 'scripts/test_env.py setup'. Then you can run the following command to run the python library test suite. |
| 75 | +2. In this repository (the Iroha Python one), run: |
| 76 | + ```sh |
| 77 | + poetry run python -m pytest tests/ |
| 78 | + ``` |
| 79 | + This command will execute the test suite, verifying the library’s functionality. |
37 | 80 |
|
38 |
| -```sh |
39 |
| -poetry run python -m pytest tests/ |
40 |
| -``` |
| 81 | +## Additional Resources |
| 82 | + |
| 83 | +- [Hyperledger Iroha 2 Documentation](https://github.com/hyperledger/iroha) |
| 84 | +- [Official Iroha Python Repository](https://github.com/hyperledger/iroha-python) |
0 commit comments