mchardysam / python-binance-chain

Binance Chain Exchange API python implementation for automated trading
http://python-binance-chain.rtfd.io
MIT License
303 stars 132 forks source link

Remove pywallet and replace with pycoin for bip32 #30

Closed cheeseandcereal closed 3 years ago

cheeseandcereal commented 5 years ago

Fixes #29

pywallet brings in a ridiculous amount of (strict) dependencies, and is only used for bip32 wallet generation.

I've replaced this with pycoin which doesn't carry any extra dependencies with it for bip32 wallet generation.

Before: image (~81MB of required dependencies)

After: image (~36MB of required dependencies)

cheeseandcereal commented 5 years ago

@sammchardy Any news on the ability to merge this and put it into a release?

lobatt commented 4 years ago

Hi @cheeseandcereal

I tried to use this branch to install the latest python-binance-chain module, it installed without issue, however, I could not import anything under binance_chain without my python interpreter aborting...

I am using MacOS 10.15.1 + pipenv + python 3.7.4, I also tried with pip, they have the same behavior.

(test) % pipenv graph
python-binance-chain==0.1.20
  - aiohttp [required: >=3.5.4, installed: 3.6.2]
    - async-timeout [required: >=3.0,<4.0, installed: 3.0.1]
    - attrs [required: >=17.3.0, installed: 19.3.0]
    - chardet [required: >=2.0,<4.0, installed: 3.0.4]
    - multidict [required: >=4.5,<5.0, installed: 4.6.1]
    - yarl [required: >=1.0,<2.0, installed: 1.1.0]
      - idna [required: >=2.0, installed: 2.8]
      - multidict [required: >=4.0, installed: 4.6.1]
  - mnemonic [required: >=0.18, installed: 0.19]
  - protobuf [required: >=3.6.1, installed: 3.11.0]
    - setuptools [required: Any, installed: 42.0.2]
    - six [required: >=1.9, installed: 1.13.0]
  - pycoin [required: >=0.90.20190630, installed: 0.90.20190728]
  - requests [required: >=2.21.0, installed: 2.22.0]
    - certifi [required: >=2017.4.17, installed: 2019.11.28]
    - chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
    - idna [required: >=2.5,<2.9, installed: 2.8]
    - urllib3 [required: >=1.21.1,<1.26,!=1.25.1,!=1.25.0, installed: 1.25.7]
  - secp256k1 [required: >=0.13.2, installed: 0.13.2]
    - cffi [required: >=1.3.0, installed: 1.13.2]
      - pycparser [required: Any, installed: 2.19]
  - ujson [required: >=1.35, installed: 1.35]
  - websockets [required: >=7.0, installed: 8.1]

(test) % python
Python 3.7.4 (default, Oct 17 2019, 11:14:04)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from binance_chain.wallet import Wallet
zsh: abort      python

Any idea what could cause this?

cheeseandcereal commented 4 years ago

@lobatt You probably have a dependency issue. Probably something to do with ffi or one of the crypto c-libraries

Assuming you have brew installed, try running brew install automake pkg-config libtool libffi gmp and try again with a fresh pipenv.

I made a quick dockerfile

FROM python:3.7

RUN apt update && \
    apt install -y libsecp256k1-dev && \
    pip install --no-cache git+https://github.com/cheeseandcereal/python-binance-chain.git@remove_pywallet

CMD [ "python", "-c", "from binance_chain.wallet import Wallet; print(Wallet.create_wallet_from_mnemonic('some mnemonic')._private_key)" ]

And running docker build . -t test && docker run test works fine, and outputs 31288bbe5feb587d902e45db92bc64edb8f79f9e7d465e762abfc2fb58f9d79d as I would expect, so I don't know why macos would be giving any different behavior aside from dependency issues.

lobatt commented 4 years ago

Hi @cheeseandcereal,

Thanks for looking into this, I tried to follow your instructions, got the same result. My theory right now is that this is something related to MacOS, will dig a little bit more at my side, thanks for your help.

% pipenv install -e git+https://github.com/cheeseandcereal/python-binance-chain.git@remove_pywallet#egg=python-binance-chain
Installing -e git+https://github.com/cheeseandcereal/python-binance-chain.git@remove_pywallet#egg=python-binance-chain…
Adding python-binance-chain to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (da2ea6) out of date, updating to (00be38)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
⠼ Pinning VCS Packages...Branch 'remove_pywallet' set up to track remote branch 'remove_pywallet' from 'origin'.
Switched to a new branch 'remove_pywallet'
✔ Success!
Updated Pipfile.lock (da2ea6)!
Installing dependencies from Pipfile.lock (da2ea6)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 20/20 — 00:00:04
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
% pipenv shell
Launching subshell in virtual environment…
 . /Users/lobatt/.local/share/virtualenvs/test-sBvkGOgh/bin/activate
(test) % python
Python 3.7.4 (default, Oct 17 2019, 11:14:04)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from binance_chain.wallet import Wallet
zsh: abort      python

And here is my (test) % cat Pipfile

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
python-binance-chain = {editable = true,git = "https://github.com/cheeseandcereal/python-binance-chain.git",ref = "remove_pywallet"}

[requires]
python_version = "3.7"
ghost commented 3 years ago

@sammchardy can we get this in there? I am experiencing this problem currently.

sammchardy commented 3 years ago

thanks @cheeseandcereal