mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 08:58:14 +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:
parent
ef736e837c
commit
85a32d01b9
22
setup.py
22
setup.py
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -20,18 +21,25 @@ install_requires = [
|
|||||||
'libusb1>=1.6.4',
|
'libusb1>=1.6.4',
|
||||||
]
|
]
|
||||||
|
|
||||||
from trezorlib import __version__ as VERSION
|
|
||||||
|
|
||||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||||
TREZOR_COMMON = os.path.join(CWD, 'vendor', 'trezor-common')
|
TREZOR_COMMON = os.path.join(CWD, 'vendor', 'trezor-common')
|
||||||
|
|
||||||
|
|
||||||
def read(name):
|
def read(*path):
|
||||||
filename = os.path.join(CWD, name)
|
filename = os.path.join(CWD, *path)
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
return f.read()
|
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):
|
class PrebuildCommand(Command):
|
||||||
description = 'update vendored files (coins.json, protobuf messages)'
|
description = 'update vendored files (coins.json, protobuf messages)'
|
||||||
user_options = []
|
user_options = []
|
||||||
@ -47,11 +55,11 @@ class PrebuildCommand(Command):
|
|||||||
common_defs = os.path.join(TREZOR_COMMON, 'defs')
|
common_defs = os.path.join(TREZOR_COMMON, 'defs')
|
||||||
if not os.path.exists(common_defs):
|
if not os.path.exists(common_defs):
|
||||||
raise DistutilsError('trezor-common submodule seems to be missing.\n' +
|
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
|
# generate and copy coins.json to the tree
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
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)
|
subprocess.check_call([sys.executable, build_coins], cwd=tmpdir)
|
||||||
shutil.copy(os.path.join(tmpdir, 'coins.json'), os.path.join(CWD, 'trezorlib', 'coins.json'))
|
shutil.copy(os.path.join(tmpdir, 'coins.json'), os.path.join(CWD, 'trezorlib', 'coins.json'))
|
||||||
|
|
||||||
@ -84,7 +92,7 @@ _patch_prebuild(develop)
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='trezor',
|
name='trezor',
|
||||||
version=VERSION,
|
version=find_version(),
|
||||||
author='TREZOR',
|
author='TREZOR',
|
||||||
author_email='info@trezor.io',
|
author_email='info@trezor.io',
|
||||||
license='LGPLv3',
|
license='LGPLv3',
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = '0.10.2'
|
__version__ = "0.10.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user