build: support new tooling in trezor-common

pull/25/head
matejcik 6 years ago
parent e5c2329b80
commit d235875e5e

@ -1,11 +1,10 @@
#!/usr/bin/env python3
import glob
import json
import os.path
import re
import shutil
import subprocess
import sys
import tempfile
from distutils.errors import DistutilsError
from setuptools import Command, find_packages, setup
@ -42,6 +41,22 @@ def find_version():
raise RuntimeError("Version string not found")
def build_coins_json(dst):
TOOLS_PATH = os.path.join(TREZOR_COMMON, "tools")
sys.path.insert(0, TOOLS_PATH)
import coin_info
coins = coin_info.coin_info().bitcoin
support = coin_info.support_info(coins)
for coin in coins:
coin["support"] = support[coin["key"]]
with open(dst, "w") as f:
json.dump(coins, f, indent=2, sort_keys=True)
del sys.path[0]
class PrebuildCommand(Command):
description = "update vendored files (coins.json, protobuf messages)"
user_options = []
@ -58,17 +73,12 @@ class PrebuildCommand(Command):
if not os.path.exists(common_defs):
raise DistutilsError(
"trezor-common submodule seems to be missing.\n"
+ 'Use "git submodule update --init" to retrieve it.'
+ "Use 'git submodule update --init' to retrieve it."
)
# generate and copy coins.json to the tree
with tempfile.TemporaryDirectory() as tmpdir:
build_coins = os.path.join(TREZOR_COMMON, "tools", "cointool.py")
subprocess.check_call([sys.executable, build_coins], cwd=tmpdir)
shutil.copy(
os.path.join(tmpdir, "coins.json"),
os.path.join(CWD, "trezorlib", "coins.json"),
)
coins_json = os.path.join(CWD, "trezorlib", "coins.json")
build_coins_json(coins_json)
# regenerate messages
try:

@ -48,7 +48,8 @@ def _insight_for_coin(coin):
__all__ = ["by_name", "slip44", "tx_api"]
try:
by_name = _load_coins_json()
coins_list = _load_coins_json()
by_name = {coin["name"]: coin for coin in coins_list}
except Exception as e:
raise ImportError("Failed to load coins.json. Check your installation.") from e

@ -1 +1 @@
Subproject commit d8f8c882d5dcad7b90cecb593b424556835c8961
Subproject commit d5972438919239debf4975329476c181a4fed6ea
Loading…
Cancel
Save