diff --git a/catalyst/marketplace/marketplace.py b/catalyst/marketplace/marketplace.py index 68088c5c..e972b750 100644 --- a/catalyst/marketplace/marketplace.py +++ b/catalyst/marketplace/marketplace.py @@ -23,7 +23,7 @@ from catalyst.exchange.utils.stats_utils import set_print_settings from catalyst.marketplace.marketplace_errors import ( MarketplacePubAddressEmpty, MarketplaceDatasetNotFound, MarketplaceNoAddressMatch, MarketplaceHTTPRequest, - MarketplaceNoCSVFiles) + MarketplaceNoCSVFiles, MarketplaceRequiresPython3) from catalyst.marketplace.utils.auth_utils import get_key_secret, \ get_signed_headers from catalyst.marketplace.utils.bundle_utils import merge_bundles @@ -44,7 +44,10 @@ log = logbook.Logger('Marketplace', level=LOG_LEVEL) class Marketplace: def __init__(self): global Web3 - from web3 import Web3, HTTPProvider + try: + from web3 import Web3, HTTPProvider + except ImportError: + raise MarketplaceRequiresPython3() self.addresses = get_user_pubaddr() @@ -58,7 +61,7 @@ class Marketplace: self.web3 = Web3(HTTPProvider(ETH_REMOTE_NODE)) contract_url = urllib.urlopen(MARKETPLACE_CONTRACT) - + self.mkt_contract_address = Web3.toChecksumAddress( contract_url.readline().decode( contract_url.info().get_content_charset()).strip()) @@ -72,7 +75,7 @@ class Marketplace: ) contract_url = urllib.urlopen(ENIGMA_CONTRACT) - + self.eng_contract_address = Web3.toChecksumAddress( contract_url.readline().decode( contract_url.info().get_content_charset()).strip()) @@ -150,13 +153,13 @@ class Marketplace: 'Gas Price:\t\t[Accept the default value]\n' 'Nonce:\t\t\t{nonce}\n' 'Data:\t\t\t{data}\n'.format( - _from=from_address, - to=tx['to'], - value=tx['value'], - gas=tx['gas'], - nonce=tx['nonce'], - data=tx['data'], ) - ) + _from=from_address, + to=tx['to'], + value=tx['value'], + gas=tx['gas'], + nonce=tx['nonce'], + data=tx['data'], ) + ) signed_tx = input('Copy and Paste the "Signed Transaction" ' 'field here:\n') @@ -261,14 +264,14 @@ class Marketplace: 'buy: {} ENG. Get enough ENG to cover the costs of the ' 'monthly\nsubscription for what you are trying to buy, ' 'and try again.'.format( - address, from_grains(balance), price)) + address, from_grains(balance), price)) return while True: agree_pay = input('Please confirm that you agree to pay {} ENG ' 'for a monthly subscription to the dataset "{}" ' 'starting today. [default: Y] '.format( - price, dataset)) or 'y' + price, dataset)) or 'y' if agree_pay.lower() not in ('y', 'n'): print("Please answer Y or N.") else: @@ -371,7 +374,7 @@ class Marketplace: 'You can now ingest this dataset anytime during the ' 'next month by running the following command:\n' 'catalyst marketplace ingest --dataset={}'.format( - dataset, address, dataset)) + dataset, address, dataset)) def process_temp_bundle(self, ds_name, path): """ @@ -428,10 +431,10 @@ class Marketplace: print('Your subscription to dataset "{}" expired on {} UTC.' 'Please renew your subscription by running:\n' 'catalyst marketplace subscribe --dataset={}'.format( - ds_name, - pd.to_datetime(check_sub[4], unit='s', utc=True), - ds_name) - ) + ds_name, + pd.to_datetime(check_sub[4], unit='s', utc=True), + ds_name) + ) if 'key' in self.addresses[address_i]: key = self.addresses[address_i]['key'] diff --git a/catalyst/marketplace/marketplace_errors.py b/catalyst/marketplace/marketplace_errors.py index b6be1c3b..488c204f 100644 --- a/catalyst/marketplace/marketplace_errors.py +++ b/catalyst/marketplace/marketplace_errors.py @@ -9,7 +9,8 @@ def silent_except_hook(exctype, excvalue, exctraceback): MarketplaceNoAddressMatch, MarketplaceHTTPRequest, MarketplaceNoCSVFiles, MarketplaceContractDataNoMatch, MarketplaceSubscriptionExpired, MarketplaceJSONError, - MarketplaceWalletNotSupported, MarketplaceEmptySignature]: + MarketplaceWalletNotSupported, MarketplaceEmptySignature, + MarketplaceRequiresPython3]: fn = traceback.extract_tb(exctraceback)[-1][0] ln = traceback.extract_tb(exctraceback)[-1][1] print("Error traceback: {1} (line {2})\n" @@ -86,3 +87,11 @@ class MarketplaceJSONError(ZiplineError): 'The configuration file {file} is malformed. Please correct ' 'the following error:\n{error}' ) + + +class MarketplaceRequiresPython3(ZiplineError): + msg = ( + '\nCatalyst requires Python3 to access the Enigma Data Marketplace.\n' + 'If you want to use the Data Marketplace, you need to reinstall ' + 'Catalyst\nwith Python3. See the documentation website for additional ' + 'information.') diff --git a/etc/python2.7-environment.yml b/etc/python2.7-environment.yml index b2e2486c..3835d7d4 100644 --- a/etc/python2.7-environment.yml +++ b/etc/python2.7-environment.yml @@ -23,7 +23,9 @@ dependencies: - bottleneck==1.2.1 - chardet==3.0.4 - ccxt==1.10.1094 - - web3==4.0.0b7 +# The Enigma Data Marketplace requires Python3 because it depends on +# web3, which requires Python3, as building its dependencies breaks in Python2 +# - web3==4.0.0b7 - requests-toolbelt==0.8.0 - click==6.7 - contextlib2==0.5.5 diff --git a/etc/requirements.txt b/etc/requirements.txt index 73573e45..5be47e3d 100644 --- a/etc/requirements.txt +++ b/etc/requirements.txt @@ -84,5 +84,5 @@ tables==3.3.0 ccxt==1.10.1094 boto3==1.4.8 redo==1.6 -web3==4.0.0b11 +web3==4.0.0b11; python_version > '3.4' requests-toolbelt==0.8.0 diff --git a/etc/requirements_marketplace.txt b/etc/requirements_marketplace.txt deleted file mode 100644 index 2a56c200..00000000 --- a/etc/requirements_marketplace.txt +++ /dev/null @@ -1,2 +0,0 @@ -web3==4.0.0b7 -requests-toolbelt==0.8.0