spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.44k stars 3.09k forks source link

electrum_ecc fails to install on windows #9251

Closed thecockatiel closed 2 weeks ago

thecockatiel commented 3 weeks ago

recently electrum_ecc package was used it fails to install on windows:

Collecting electrum_ecc
  Using cached electrum_ecc-0.0.3.tar.gz (2.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: electrum_ecc
  Building wheel for electrum_ecc (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for electrum_ecc (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      running bdist_wheel
      error: [WinError 193] %1 is not a valid Win32 application
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for electrum_ecc
Failed to build electrum_ecc
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (electrum_ecc)
SomberNight commented 3 weeks ago

related https://github.com/spesmilo/electrum/pull/9234

Right... This is because when you install electrum-ecc, it tries to compile libsecp256k1 from source, which of course fails on Windows. You can opt-out of the compilation by setting ELECTRUM_ECC_DONT_COMPILE=1 (as an env var). Still, you will have to get a libsecp256k1-*.dll from somewhere and put it either into electrum/ or into the unpacked electrum-ecc package.

The root of this issue is not new, it has been difficult to run Electrum from source on Windows ever since we started depending on libsecp256k1. See https://github.com/spesmilo/electrum/issues/5976 So it is only somewhat related to the recent introduction of the electrum-ecc package.

Also see contrib/build-wine/README_windows.md -- maybe we should update that and make things clearer somehow. Also, maybe when pip installing electrum-ecc on Windows, we should not even try to compile libsecp. (and then fail at runtime if the dll is not found. So we would be back to exactly where we were before the introduction of electrum-ecc, to https://github.com/spesmilo/electrum/issues/5976)

EDIT: at the very least we should try to improve the error message, because the error shown in the OP is really unclear.

thecockatiel commented 3 weeks ago

I did compile the libsecp256k1 dll using wsl and could run electrum from source fairly easily at 9a5edfdd74972d935247d15b3be41b254ee3a07e (It just happen to be where I cloned the repo I guess) using ELECTRUM_ECC_DONT_COMPILE=1 I managed to install the package and run from source again on latest commit successfully thanks for the help

yeah I think it's a good idea to simply skip compiling libsecp on windows when pip installing, that should help without the need to update the guide

SomberNight commented 2 weeks ago

at the very least we should try to improve the error message, because the error shown in the OP is really unclear.

done in https://github.com/spesmilo/electrum-ecc/commit/94b751c6cf55a72095d37d948ed8ffe4a43e85dc

yeah I think it's a good idea to simply skip compiling libsecp on windows when pip installing

done in https://github.com/spesmilo/electrum-ecc/commit/a069a6305e581a1294cd203f8772762f28c1e890