chainside / btcpy

A Python3 SegWit-compliant library which provides tools to handle Bitcoin data structures in a simple fashion.
https://www.chainside.net
GNU Lesser General Public License v3.0
271 stars 74 forks source link

Installation and Build errors #52

Closed maxcado closed 5 years ago

maxcado commented 5 years ago

First, I wonder whether you realize that one cannot pip install chainside-btcpy. This is the message received "Could not find a version that satisfies the requirement chainside-btcpy (from versions:). No matching distribution found for chainside btcpy.

Secondly, when one does a git clone to download the repository, there are SyntaxErrors with the setup.py file. One error samples is as follows: byte-compiling build/bdist.linux-x86_64/egg/btcpy/structs/hd.py to hd.pyc File "build/bdist.linux-x86_64/egg/btcpy/structs/hd.py", line 29 class ExtendedKey(HexSerializable, metaclass=ABCMeta): SyntaxError: invalid syntax ----- arrow is under the equal sign between metaclass=ABCMeta.

This is just one example of SyntaxErrors.

Due to these errors cannot use this library. In the python environment, 'from btcpy.setup import setup' outputs SyntaxError: invalid syntax for line 23 of btcpy/setup.py .

Please advise as to how to properly install.

SimoneBronzini commented 5 years ago

Please keep in mind that btcpy is a Python3 library. If pip install chainside-btcpy is not finding any package to install, it is probably because your system is assuming Python2 by default. This would also explain all the subsequent syntax errors. If you have python3 and pip3 installed on your system, you should install btcpy with pip3 install chainside-btcpy and you should be able to use the library on python3 projects by runnning them using the command python3 instead of python

maxcado commented 5 years ago

Thank you for your speedy response. I appreciate that. Your suggestion worked. My system default on Ubuntu Bionic is python 2. I used pip3 install chainside-btcpy and it worked. To get into the python environment, I did python3 and using python 3.6.5.

However, I note that in setting up the network, I get the following:

from btcpy.setup import setup setup('regtest', strict=True) {'netname': None, 'mainnet': None, 'strict': None}

If I try to do setup('regtest') I get the following: {'netname': 'regtest', 'mainnet': False, 'strict': True}

How to resolve this?

SimoneBronzini commented 5 years ago

I see that it might be a bit confusing but that is the expected behaviour. When you run setup the output you get is the previous setup state, not the one you just set. The idea behind this is that you can switch between two configurations by doing, for instance:

prev = setup('regtest', strict=True)
# do something with this configuration
setup(prev['netname'], strict=prev['strict']) # restore previous configuration