diff --git a/bindings/python/README.md b/bindings/python/README.md
index 764da8ac9..abaead637 100644
--- a/bindings/python/README.md
+++ b/bindings/python/README.md
@@ -8,11 +8,12 @@
1. Run your local Hornet
- `$ git clone git@github.com:gohornet/hornet.git`
-- checkout `chrysalis-pt2` branch
-- Modify your `create_snapshot_alphanet.sh`, modify Line 14 to `go run ../main.go tool snapgen alphanet1 96f9de0989e77d0e150e850a5a600e83045fa57419eaf3b20225b763d4e23813 snapshots/alphanet1/full_export.bin`
-- `$ ./run_coo_bootstrap.sh `
+- checkout `develop` branch
+- Modify your `create_snapshot_alphanet.sh`, modify Line 14 to `go run "..\main.go" tool snapgen alphanet1 96f9de0989e77d0e150e850a5a600e83045fa57419eaf3b20225b763d4e23813 1000000000 "snapshots\alphanet1\full_export.bin"`
+- Go to `hornet/alphanet`
+- `$ ./run_coo_bootstrap.sh`
-2. To build the iota_client python library by yourself, there are two ways.
+1. To build the iota_client python library by yourself, there are two ways.
- By using the `cargo`
- Go to `bindings/python/native`
- `$ cargo build --release`
@@ -29,7 +30,7 @@
- The wheel file is now created in `bindings/python/native/target/wheels`
- `$ pip3 install [THE_BUILT_WHEEL_FILE]`
-3. To use the pre-build libraries
+2. To use the pre-build libraries
- To use the pre-built libraries for linux/macos/windows, please check the `Artifacts` files generated by the Github Action in the last commit. For example, there are the following 12 wheels in [this commit](https://github.com/iotaledger/iota.rs/actions/runs/596639195). Please download the one which matches your os and python version.
- [linux-iota-client-py3.6-wheel](https://github.com/iotaledger/iota.rs/suites/2115209642/artifacts/43080898)
- [linux-iota-client-py3.7-wheel](https://github.com/iotaledger/iota.rs/suites/2115209642/artifacts/43080899)
@@ -46,6 +47,14 @@
- **NOTE: Please download the wheel files generated in the commit version you want to use.**
- `$ pip3 install [THE_DOWNLOADED_WHEEL_FILE]`
+## Testing
+- Install [tox](#https://pypi.org/project/tox/)
+ - `$ pip install tox`
+- Build the library
+ - `$ python setup.py install`
+- To test install tox globally and run
+ - `$ tox -e py`
+
## Python Example
```python
import iota_client
@@ -176,8 +185,8 @@ Creates a new instance of the Client.
| --------------------- | -------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [network] | str
| undefined
| The network |
| [node] | str
| undefined
| A node URL |
-| [name] | str
| undefined
| The name for basic authentication |
-| [password] | str
| undefined
| The password for basic authentication |
+| [name] | str
| undefined
| The name for basic authentication |
+| [password] | str
| undefined
| The password for basic authentication |
| [nodes] | list[str]
| undefined
| An array of node URLs |
| [node_sync_interval] | int
| undefined
| The interval for the node syncing process |
| [node_sync_disabled] | bool
| undefined
| Disables the node syncing process. Every node will be considered healthy and ready to use |
@@ -469,7 +478,7 @@ Retries (promotes or reattaches) the message associated with the given id.
| ------------ | ---------------- | ---------------------- | ------------------------------------------------------ |
| [message_id] | str
| undefined
| The message id |
| interval | int
| 5
| The interval in seconds in which we retry the message. |
-| max_attempts | int
| 10
| The maximum of attempts we retry the message. |
+| max_attempts | int
| 10
| The maximum of attempts we retry the message. |
**Returns** the message ids and [Message](#message) of reattached messages.
diff --git a/bindings/python/native/MANIFEST.in b/bindings/python/native/MANIFEST.in
new file mode 100644
index 000000000..4b8d0b8f4
--- /dev/null
+++ b/bindings/python/native/MANIFEST.in
@@ -0,0 +1,2 @@
+include pyproject.toml Cargo.toml
+recursive-include src *
\ No newline at end of file
diff --git a/bindings/python/native/iota_client/__init__.py b/bindings/python/native/iota_client/__init__.py
new file mode 100644
index 000000000..9e20fb865
--- /dev/null
+++ b/bindings/python/native/iota_client/__init__.py
@@ -0,0 +1 @@
+from .iota_client import *
diff --git a/bindings/python/native/requirements-dev.txt b/bindings/python/native/requirements-dev.txt
new file mode 100644
index 000000000..ccd1b78eb
--- /dev/null
+++ b/bindings/python/native/requirements-dev.txt
@@ -0,0 +1,4 @@
+pip>=19.1
+pytest>=3.5.0
+setuptools-rust>=0.10.2
+psutil>=5.6
diff --git a/bindings/python/native/setup.py b/bindings/python/native/setup.py
new file mode 100644
index 000000000..483561635
--- /dev/null
+++ b/bindings/python/native/setup.py
@@ -0,0 +1,45 @@
+
+import sys
+import platform
+
+from setuptools import setup
+from setuptools_rust import RustExtension
+
+
+def get_py_version_cfgs():
+ # For now each Cfg Py_3_X flag is interpreted as "at least 3.X"
+ version = sys.version_info[0:2]
+ py3_min = 6
+ out_cfg = []
+ for minor in range(py3_min, version[1] + 1):
+ out_cfg.append("--cfg=Py_3_%d" % minor)
+
+ if platform.python_implementation() == "PyPy":
+ out_cfg.append("--cfg=PyPy")
+
+ return out_cfg
+
+
+setup(
+ name="iota_client",
+ version="0.1.0",
+ classifiers=[
+ "License :: SPDX-License-Identifier :: Apache-2.0",
+ "Development Status :: 0.1.0 - Alpha",
+ "Intended Audience :: Developers",
+ "Programming Language :: Python",
+ "Programming Language :: Rust",
+ "Operating System :: POSIX",
+ "Operating System :: MacOS :: MacOS X",
+ ],
+ packages=["iota_client"],
+ rust_extensions=[
+ RustExtension(
+ "iota_client.iota_client",
+ rustc_flags=get_py_version_cfgs(),
+ debug=False,
+ ),
+ ],
+ include_package_data=True,
+ zip_safe=False,
+)
diff --git a/bindings/python/native/tests/test_api.py b/bindings/python/native/tests/test_api.py
new file mode 100644
index 000000000..141b9f1ab
--- /dev/null
+++ b/bindings/python/native/tests/test_api.py
@@ -0,0 +1,60 @@
+# Copyright 2021 IOTA Stiftung
+# SPDX-License-Identifier: Apache-2.0
+
+import iota_client
+import os
+
+TEST_NODE_URL = "https://api.lb-0.testnet.chrysalis2.com"
+
+# NOTE! Load the seed from your env path instead
+# NEVER assign the seed directly in your codes!
+# DO NOT USE THIS!!:
+# SEED = "256a818b2aac458941f7274985a410e57fb750f3a3a67969ece5bd9ae7eef5b2"
+
+# USE THIS INSTEAD
+SEED = os.getenv('NONSECURE_USE_OF_DEVELOPMENT_SEED_1')
+EMPTY_ADDRESS = "atoi1qzt0nhsf38nh6rs4p6zs5knqp6psgha9wsv74uajqgjmwc75ugupx3y7x0r"
+client = iota_client.Client(node=TEST_NODE_URL)
+
+def test_get_health():
+ health = client.get_health()
+
+def test_get_info():
+ node_info = client.get_info()
+
+def test_get_tips():
+ tips = client.get_tips()
+
+def test_get_addresses():
+ address_changed_list = client.get_addresses(
+ seed=SEED, account_index=0, input_range_begin=0, input_range_end=10, get_all=True)
+
+ # Get the (address, changed ) for the first found address
+ address, changed = address_changed_list[0]
+ balance = client.get_address_balance(address)
+
+def test_get_address_balance():
+ balance = client.get_address_balance(EMPTY_ADDRESS)
+
+def test_get_address_outputs():
+ outputs = client.get_address_outputs(EMPTY_ADDRESS)
+
+def test_indexation_with_int_list_data():
+ message_id_indexation = client.message(
+ index="Hello", data=[84, 97, 110, 103, 108, 101])
+
+def test_indexation_with_data_str():
+ message_id_indexation = client.message(
+ index="Hi", data_str="Tangle")
+
+def test_get_message_index():
+ message_id_indexation_queried = client.get_message_index("Hello")
+
+def test_find_messages():
+ messages = client.find_messages(indexation_keys=["Hello"])
+
+def test_get_unspent_address():
+ unspent_addresses = client.get_unspent_address(seed=SEED)
+
+def test_get_balance_in_seed():
+ balance = client.get_balance(seed=SEED)
\ No newline at end of file
diff --git a/bindings/python/native/tox.ini b/bindings/python/native/tox.ini
new file mode 100644
index 000000000..7ef90b46a
--- /dev/null
+++ b/bindings/python/native/tox.ini
@@ -0,0 +1,10 @@
+[tox]
+# can't install from sdist because local pyo3 repo can't be included in the sdist
+skipsdist = true
+
+[testenv]
+description = Run the unit tests under {basepython}
+deps = -rrequirements-dev.txt
+commands =
+ python setup.py install
+ pytest
\ No newline at end of file