1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

build: do not import trezorlib in setup.py, parse out __version__ by hand

also update path to coin generating tool
This commit is contained in:
matejcik 2018-07-03 15:53:16 +02:00
parent ef736e837c
commit 85a32d01b9
2 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import os.path
import re
import shutil
import subprocess
import sys
@ -20,18 +21,25 @@ install_requires = [
'libusb1>=1.6.4',
]
from trezorlib import __version__ as VERSION
CWD = os.path.dirname(os.path.realpath(__file__))
TREZOR_COMMON = os.path.join(CWD, 'vendor', 'trezor-common')
def read(name):
filename = os.path.join(CWD, name)
def read(*path):
filename = os.path.join(CWD, *path)
with open(filename, 'r') as f:
return f.read()
def find_version():
version_file = read("trezorlib", "__init__.py")
version_match = re.search(r"^__version__ = \"(.*)\"$", version_file, re.M)
if version_match:
return version_match.group(1)
else:
raise RuntimeError("Version string not found")
class PrebuildCommand(Command):
description = 'update vendored files (coins.json, protobuf messages)'
user_options = []
@ -51,7 +59,7 @@ class PrebuildCommand(Command):
# generate and copy coins.json to the tree
with tempfile.TemporaryDirectory() as tmpdir:
build_coins = os.path.join(TREZOR_COMMON, 'defs', 'coins', 'tools', 'build_coins.py')
build_coins = os.path.join(TREZOR_COMMON, 'tools', 'build_coins.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'))
@ -84,7 +92,7 @@ _patch_prebuild(develop)
setup(
name='trezor',
version=VERSION,
version=find_version(),
author='TREZOR',
author_email='info@trezor.io',
license='LGPLv3',

View File

@ -1 +1 @@
__version__ = '0.10.2'
__version__ = "0.10.2"