hyperledger-iroha / iroha-python

Python library for Hyperledger Iroha, a simple distributed ledger.
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
103 stars 81 forks source link

Unable to build the recent version according to the documentation #129

Open 6r1d opened 2 years ago

6r1d commented 2 years ago

Today, @learningnoobi wrote that a fresh qroha-python is broken:

$ git clone https://github.com/hyperledger/iroha-python/ --branch iroha2 iroha-2-python
# ...

$ cd iroha-2-python
# ...

$ maturin build
šŸ¹ Building a mixed python/rust project

šŸ’„ maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:
    Updating git repository `https://github.com/hyperledger/iroha`
    Updating crates.io index
error: failed to select a version for `async-trait`.
    ... required by package `iroha_core v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_core` of package `iroha_client v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_client` of package `iroha_python v0.1.0 (ā€¦/iroha-2-python)`
versions that meet the requirements `^0.1.57` are: 0.1.57

all possible versions conflict with previously selected packages.

  previously selected package `async-trait v0.1.56`
    ... which satisfies dependency `async-trait = "^0.1"` (locked to 0.1.56) of package `iroha_core v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_core` (locked to 2.0.0-pre-rc.5) of package `iroha_schema_gen v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_schema_gen` (locked to 2.0.0-pre-rc.5) of package `generate v0.1.0 (ā€¦/iroha-2-python/generate)`

failed to select a version for `async-trait` which could resolve this conflict
$ rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)
$ cargo --version
cargo 1.64.0 (387270bc7 2022-09-16)

I have also notified @QuentinI.

learningnoobi commented 2 years ago

any update on this ?

6r1d commented 2 years ago

UPD: I've attempted to switch the library version to the altered Cargo.toml.

I've switched to the dev version of Iroha from the stable one.

[package]
name = "iroha_python"
version = "0.1.0"
authors = ["Iroha 2 team <https://github.com/orgs/soramitsu/teams/iroha2>"]
edition = "2021"
license-file = "LICENSE"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = ["generate"]

[lib]
name = "iroha2"
crate-type = ["cdylib"]

[dependencies]
iroha_client = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" }
iroha_crypto = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" }
iroha_data_model = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" }
iroha_version = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" }

color-eyre = "0.6"
parity-scale-codec = "3.1"
pyo3 = { version = "0.16.4", features = ["extension-module", "multiple-pymethods"] }
pythonize = "0.16.0"
serde = "1"
serde_json = "1"

Sadly, there's another build error that doesn't let this build to work.

šŸ¹ Building a mixed python/rust project
šŸ”— Found pyo3 bindings
šŸ Found CPython 3.10 at /usr/bin/python3
   Compiling proc-macro2 v1.0.47
   Compiling quote v1.0.21
   Compiling unicode-ident v1.0.5
   Compiling syn v1.0.103
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling version_check v0.9.4
   Compiling libc v0.2.137
   Compiling serde_derive v1.0.147
   Compiling serde v1.0.147
   Compiling typenum v1.15.0
   Compiling once_cell v1.15.0
   Compiling log v0.4.17
   Compiling memchr v2.5.0
   Compiling itoa v1.0.4
   Compiling thiserror v1.0.37
   Compiling hashbrown v0.12.3
   Compiling bitflags v1.3.2
   Compiling pkg-config v0.3.26
   Compiling subtle v2.4.1
   Compiling byteorder v1.4.3
   Compiling pin-project-lite v0.2.9
   Compiling fnv v1.0.7
   Compiling unicode-xid v0.2.4
   Compiling opaque-debug v0.3.0
   Compiling cpufeatures v0.2.5
   Compiling bytes v1.2.1
   Compiling stable_deref_trait v1.2.0
   Compiling fallible-iterator v0.2.0
   Compiling scopeguard v1.1.0
   Compiling ppv-lite86 v0.2.16
   Compiling lazy_static v1.4.0
   Compiling percent-encoding v2.2.0
   Compiling target-lexicon v0.12.4
   Compiling crossbeam-utils v0.8.12
   Compiling futures-core v0.3.25
   Compiling tinyvec_macros v0.1.0
   Compiling block-padding v0.2.1
   Compiling unicode-bidi v0.3.8
   Compiling rand_core v0.4.2
   Compiling adler v1.0.2
   Compiling getrandom v0.1.16
   Compiling futures-task v0.3.25
   Compiling futures-channel v0.3.25
   Compiling base64 v0.13.1
   Compiling futures-sink v0.3.25
   Compiling futures-util v0.3.25
   Compiling rustversion v1.0.9
   Compiling openssl v0.10.42
   Compiling foreign-types-shared v0.1.1
   Compiling serde_json v1.0.87
   Compiling httparse v1.8.0
   Compiling ryu v1.0.11
   Compiling pin-utils v0.1.0
   Compiling rayon-core v1.9.3
   Compiling either v1.8.0
   Compiling const-oid v0.6.2
   Compiling convert_case v0.4.0
   Compiling futures-io v0.3.25
   Compiling rustc-demangle v0.1.21
   Compiling cpuid-bool v0.2.0
   Compiling parking_lot_core v0.9.4
   Compiling anyhow v1.0.66
   Compiling num_threads v0.1.6
   Compiling byte-slice-cast v1.2.1
   Compiling arrayvec v0.7.2
   Compiling time-core v0.1.0
   Compiling byte-tools v0.3.1
   Compiling strsim v0.10.0
   Compiling keccak v0.1.2
   Compiling ident_case v1.0.1
   Compiling overload v0.1.1
   Compiling failure_derive v0.1.8
   Compiling static_assertions v1.1.0
   Compiling opaque-debug v0.2.3
   Compiling httpdate v1.0.2
   Compiling try-lock v0.2.3
   Compiling crc32fast v1.3.2
   Compiling mime v0.3.16
   Compiling eyre v0.6.8
   Compiling cranelift-isle v0.86.1
   Compiling io-lifetimes v0.7.4
   Compiling tower-service v0.3.2
   Compiling indenter v0.3.3
   Compiling crossbeam-queue v0.3.6
   Compiling miracl_core v1.0.0
   Compiling scoped-tls v1.0.0
   Compiling arrayref v0.3.6
   Compiling rustix v0.35.12
   Compiling iroha_crypto v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling heck v0.4.0
   Compiling cranelift-codegen-shared v0.86.1
   Compiling int_traits v0.1.1
   Compiling amcl v0.2.0
   Compiling linux-raw-sys v0.0.46
   Compiling iroha_data_model v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling owo-colors v3.5.0
   Compiling slice-group-by v0.3.0
   Compiling async-trait v0.1.58
   Compiling native-tls v0.2.10
   Compiling more-asserts v0.2.2
   Compiling zstd-safe v5.0.2+zstd.1.5.2
   Compiling utf-8 v0.7.6
   Compiling regex-syntax v0.6.27
   Compiling humantime v2.1.0
   Compiling leb128 v0.2.5
   Compiling termcolor v1.1.3
   Compiling cpp_demangle v0.3.5
   Compiling openssl-probe v0.1.5
   Compiling prometheus v0.13.3
   Compiling wasmtime-cache v0.39.1
   Compiling unicode-width v0.1.10
   Compiling wasmtime v0.39.1
   Compiling iana-time-zone v0.1.51
   Compiling paste v1.0.9
   Compiling wildmatch v2.1.1
   Compiling unindent v0.1.10
   Compiling indoc v1.0.7
   Compiling autocfg v0.1.8
   Compiling generic-array v0.14.6
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-mac
   Compiling tracing-error v0.2.0
   Compiling tracing-futures v0.2.5
   Compiling darling v0.14.1
   Compiling crypto-bigint v0.2.11
   Compiling curve25519-dalek v3.2.1
   Compiling chacha20 v0.6.0
   Compiling subtle-encoding v0.5.1
   Compiling futures v0.3.25
   Compiling color-spantrace v0.2.0
   Compiling serde_with_macros v2.0.1
   Compiling smallvec v1.10.0
   Compiling cranelift-entity v0.86.1
   Compiling serde_bytes v0.11.7
   Compiling secp256k1 v0.19.0
   Compiling serde_urlencoded v0.7.1
   Compiling hex v0.4.3
   Compiling bincode v1.3.3
   Compiling parity-scale-codec-derive v3.1.3
   Compiling tokio-util v0.7.4
   Compiling tokio-stream v0.1.11
   Compiling chacha20poly1305 v0.7.1
   Compiling elliptic-curve v0.10.6
   Compiling iroha_ffi v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling ed25519-dalek v1.0.1
   Compiling x25519-dalek v1.2.0
   Compiling smallstr v0.3.0
   Compiling regalloc2 v0.3.2
   Compiling gimli v0.26.2
   Compiling wasmparser v0.86.0
   Compiling object v0.28.4
   Compiling cranelift-bforest v0.86.1
   Compiling amcl_wrapper v0.4.0
   Compiling iroha_config_base v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling tracing-bunyan-formatter v0.3.4
   Compiling tungstenite v0.17.3
   Compiling serde_with v2.0.1
   Compiling h2 v0.3.15
   Compiling ecdsa v0.12.4
   Compiling tungstenite v0.16.0
   Compiling tokio-native-tls v0.3.0
   Compiling attohttpc v0.18.0
   Compiling dashmap v5.4.0
   Compiling parking_lot v0.12.1
   Compiling parity-scale-codec v3.2.1
   Compiling wasmtime-types v0.39.1
   Compiling tokio-tungstenite v0.17.2
   Compiling addr2line v0.17.0
   Compiling wasmtime-jit-debug v0.39.1
   Compiling k256 v0.9.6
   Compiling tokio-tungstenite v0.16.1
   Compiling fixnum v0.9.1
   Compiling wasmtime-environ v0.39.1
   Compiling iroha_schema v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling hyper v0.14.20
   Compiling failure v0.1.8
   Compiling color-eyre v0.6.2
   Compiling iroha_primitives v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling pythonize v0.16.0
   Compiling ursa v0.3.7
   Compiling wasmtime-jit v0.39.1
   Compiling warp v0.3.3
   Compiling cranelift-frontend v0.86.1
   Compiling cranelift-native v0.86.1
   Compiling cranelift-wasm v0.86.1
   Compiling wasmtime-cranelift v0.39.1
   Compiling iroha_version v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling git2 v0.14.4
   Compiling iroha_config v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_logger v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_futures v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_actor v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_telemetry v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling zstd v0.11.2+zstd.1.5.2
   Compiling iroha_p2p v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_core v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-dev#64078706)
   Compiling iroha_python v0.1.0 (ā€¦/iroha-python)
error[E0432]: unresolved import `iroha_client::config`a_python                                                                                              
  --> src/lib.rs:15:28
   |
15 | use iroha_client::{client, config::Configuration};
   |                            ^^^^^^ could not find `config` in `iroha_client`

error[E0433]: failed to resolve: use of undeclared type `VersionedTransaction`                                                                              
   --> src/lib.rs:109:18
    |
109 |             .map(VersionedTransaction::from)
    |                  ^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `(): PyClass` is not satisfiedon                                                                                              
  --> src/lib.rs:82:14
   |
82 |         cfg: ToPy<Configuration>,
   |              ^^^^ the trait `PyClass` is not implemented for `()`
   |
   = help: the following other types implement trait `PyClass`:
             Client
             Dict
             EventIterator
             Items
             KeyPair
             List
             dict::Keys
             dict::Values
   = note: required because of the requirements on the impl of `pyo3::FromPyObject<'_>` for `()`
note: required by a bound in `extract_argument`
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.16.6/src/impl_/extract_argument.rs:14:8
   |
14 |     T: FromPyObject<'py>,
   |        ^^^^^^^^^^^^^^^^^ required by this bound in `extract_argument`

error[E0277]: the trait bound `(): PyClass` is not satisfiedon                                                                                              
  --> src/lib.rs:72:21
   |
72 |     pub fn new(cfg: ToPy<Configuration>) -> PyResult<Self> {
   |                     ^^^^ the trait `PyClass` is not implemented for `()`
   |
   = help: the following other types implement trait `PyClass`:
             Client
             Dict
             EventIterator
             Items
             KeyPair
             List
             dict::Keys
             dict::Values
   = note: required because of the requirements on the impl of `pyo3::FromPyObject<'_>` for `()`
note: required by a bound in `extract_argument`
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.16.6/src/impl_/extract_argument.rs:14:8
   |
14 |     T: FromPyObject<'py>,
   |        ^^^^^^^^^^^^^^^^^ required by this bound in `extract_argument`

warning: unused import: `iroha_version::prelude`: iroha_python                                                                                              
  --> src/lib.rs:19:5
   |
19 | use iroha_version::prelude::*;
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

    Buildingerror: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0432, E0433.

For more information about an error, try `rustc --explain E0277`.

error: could not compile `iroha_python` due to 5 previous errors; 1 warning emitted
šŸ’„ maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `"cargo" "rustc" "--message-format" "json" "--lib"`
dittmanndennis commented 1 year ago

Which commit are you guys trying to build? I just cloned the iroha2 branch and my version conflicts start from this:

šŸ’„ maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:     Updating git repository `https://github.com/hyperledger/iroha`
    Updating crates.io index
error: failed to select a version for `crossbeam-queue`.
    ... required by package `iroha_core v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_core` of package `iroha_client v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_client` of package `iroha_python v0.1.0 (/Users/dennis/Code/iroha-python)`
versions that meet the requirements `^0.3.6` are: 0.3.6

all possible versions conflict with previously selected packages.

  previously selected package `crossbeam-queue v0.3.5`
    ... which satisfies dependency `crossbeam-queue = "^0.3.2"` (locked to 0.3.5) of package `crossbeam v0.8.2`
    ... which satisfies dependency `crossbeam = "^0.8.2"` of package `iroha_client v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_client` of package `iroha_python v0.1.0 (/Users/dennis/Code/iroha-python)`

failed to select a version for `crossbeam-queue` which could resolve this conflict

And upon resolving this and following conflicts, I am stuck trying to solve the following conflict:

šŸ’„ maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:     Updating git repository `https://github.com/hyperledger/iroha`
    Updating crates.io index
error: failed to select a version for `wasmtime-fiber`.
    ... required by package `wasmtime v0.39.1`
    ... which satisfies dependency `wasmtime = "^0.39.1"` of package `iroha_core v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_core` of package `iroha_client v2.0.0-pre-rc.9 (https://github.com/hyperledger/iroha?branch=iroha2-stable#b783f10f)`
    ... which satisfies git dependency `iroha_client` of package `iroha_python v0.1.0 (/Users/dennis/Code/iroha-python)`
versions that meet the requirements `=0.39.1` (locked to 0.39.1) are: 0.39.1

the package `wasmtime-fiber` links to the native library `wasmtime-fiber-shims`, but it conflicts with a previous package which links to `wasmtime-fiber-shims` as well:
package `wasmtime-fiber v0.36.0`
    ... which satisfies dependency `wasmtime-fiber = "=0.36.0"` of package `wasmtime v0.36.0`
    ... which satisfies dependency `wasmtime = "^0.36.0"` (locked to 0.36.0) of package `iroha_core v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_core` (locked to 2.0.0-pre-rc.5) of package `iroha_schema_gen v2.0.0-pre-rc.5 (https://github.com/hyperledger/iroha?branch=iroha2-dev#f7fac5f2)`
    ... which satisfies git dependency `iroha_schema_gen` (locked to 2.0.0-pre-rc.5) of package `generate v0.1.0 (/Users/dennis/Code/iroha-python/generate)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='wasmtime-fiber' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `wasmtime-fiber` which could resolve this conflict

Making things worse, I am working on an ARM based system (M1). Any recommendations on making iroha-python work under my system?

vpereiranunes commented 6 months ago

I did the following steps and worked for me: rustup component add rust-src --toolchain nightly-2023-06-25-x86_64-unknown-linux-gnu rustup override set nightly-2023-06-25-x86_64-unknown-linux-gnu maturin build