bitlogik / pyWalletConnect

WalletConnect implementation for Python wallets
GNU General Public License v3.0
47 stars 15 forks source link

Error when trying to install pyWalletConnect. I'm trying to install on a raspberry pi zero. Thanks!! #9

Open snarflakes opened 1 year ago

snarflakes commented 1 year ago

I already updated pip. Thanks.

Note: sudo pip install cryptography says requirement already satisfied

writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
/tmp/pip-build-env-sk55fnkj/lib/python3.7/site-packages/setuptools/command/build_py.py:202: SetuptoolsDeprecationWarning:     Installing 'cryptography.hazmat.bindings._rust' as data is deprecated, please list it in `packages`.
    !!

    ############################
    # Package would be ignored #
    ############################
    Python recognizes 'cryptography.hazmat.bindings._rust' as an importable package,
    but it is not listed in the `packages` configuration of setuptools.

    'cryptography.hazmat.bindings._rust' has been automatically added to the distribution only
    because it may contain data files, but this behavior is likely to change
    in future versions of setuptools (and therefore is considered deprecated).

    Please make sure that 'cryptography.hazmat.bindings._rust' is included as a package by using
    the `packages` configuration field or the proper discovery methods
    (for example by using `find_namespace_packages(...)`/`find_namespace:`
    instead of `find_packages(...)`/`find:`).

    You can read more about "package discovery" and "data files" on setuptools
    documentation page.

!!

  check.warn(importable)
copying src/cryptography/py.typed -> build/lib.linux-armv6l-cpython-37/cryptography
copying src/cryptography/hazmat/bindings/_openssl.pyi -> build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings
creating build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings/_rust
copying src/cryptography/hazmat/bindings/_rust/__init__.pyi -> build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings/_rust
copying src/cryptography/hazmat/bindings/_rust/asn1.pyi -> build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings/_rust
copying src/cryptography/hazmat/bindings/_rust/ocsp.pyi -> build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings/_rust
copying src/cryptography/hazmat/bindings/_rust/x509.pyi -> build/lib.linux-armv6l-cpython-37/cryptography/hazmat/bindings/_rust
running build_ext
running build_rust

    =============================DEBUG ASSISTANCE=============================
    If you are seeing a compilation error please try the following steps to
    successfully install cryptography:
    1) Upgrade to the latest pip and try again. This will fix errors for most
       users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
    2) Read https://cryptography.io/en/latest/installation/ for specific
       instructions for your platform.
    3) Check our frequently asked questions for more information:
       https://cryptography.io/en/latest/faq/
    4) Ensure you have a recent Rust toolchain installed:
       https://cryptography.io/en/latest/installation/#rust

    Python: 3.7.3
    platform: Linux-5.10.17+-armv6l-with-debian-10.8
    pip: 18.1
    setuptools: 65.6.3
    setuptools_rust: 1.5.2
    rustc: n/a
    =============================DEBUG ASSISTANCE=============================

error: can't find Rust compiler

If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

To update pip, run:

    pip install --upgrade pip

and then retry package installation.

If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.

This package requires Rust >=1.48.0.

----------------------------------------

Can't roll back cryptography; was not uninstalled Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-hlenyg9p/cryptography/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-51ogsqmr/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-hlenyg9p/cryptography/


New errors:

Building wheel for cryptography (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for cryptography (pyproject.toml) did not run successfully. │ exit code: 1 note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for cryptography Failed to build cryptography ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects

snarflakes commented 1 year ago

Problem solved. Needed to install various dev tools and precursors and it was able to finish building the wheel.

openssl

Rust

Setup-rust

snarflakes commented 1 year ago

I was able to install this non-sudo. But I'm having a lot of difficulty installing it as sudo. I think it is the cryptography module that is holding up the install. I was able to sudo install cryptography via cryptography apt-install instead of PIP. Can you add "requirement already satisfied" for cryptography so it skips it when building pywalletconnect, that will hopefully allow me to move forward with the install as sudo? thanks!

More detail: looks like my system is having difficulty upgrading cryptography to the required version. Maybe I can sort this out. non-sudo version oddly appears to be 38?? while stuck sudo version is 2.6.1 "cryptography>=3.3", "wsproto==1.0.0",

bitlogik commented 1 year ago

On Linux, many Python packages with heavy C bindings are usually much easier to installed using the system package manager. This provides already compiled binary packages. The issue with this method is that the version is quite old. Even on an not so old Debian 10 you get v2.6.1 for cryptography for example.

I think we can downgrade the version requirement here, but that could downgrade the security. We setup to 3.3 because this is the version on Debian Bulleye 11. One method to solve this would be for you to use a more recent Linux system (Debian 11, Ubuntu 22.04, ...). As this is a crypto wallet usage, that would beef up the security.

Since pyWalletConnect has very little dependencies, and that's in the DNA of all our Python code, you can just install the other packages manually. Why using the setup file just for one remaining dependency? And pyWalletConnect doesn't need any build or compilation (it is pure-Python, so does wsproto)

You can do that :

sudo apt update
sudo apt install python3-cryptography
python3 -m pip install --upgrade pip
python3 -m pip install wsproto==1.0.0

And then you provide pyWalletConnect in its directory in your project, it should work.

Alternatively, you can downgrade the requirement yourself, and change setup.py L17 to "cryptography>=2.6", That will install pyWalletConnect system-wide, if you need it for multiple software projects.

snarflakes commented 1 year ago

Like usual, you all make things super clear. I'm really grateful I was able to get this working as a "non-sudo" user. I now need pywalletconnect as root, unfortunately i didn't write down all the previous steps! I'm either going to try your above alternative recommendations, or I will figure out how i can recreate the steps I did previously, I will post them here when i figure it out. For future pi users here is a link to the discussion about problems with cryptography module on pi devices. cryptography module issues