Add a hwi.spec file for pyinstaller to build standalone binaries
This commit is contained in:
parent
d6b24b853d
commit
9e04d1a16a
4
contrib/pyinstaller-hooks/hook-hwilib.devices.py
Normal file
4
contrib/pyinstaller-hooks/hook-hwilib.devices.py
Normal file
@ -0,0 +1,4 @@
|
||||
from hwilib.devices import __all__
|
||||
hiddenimports = []
|
||||
for d in __all__:
|
||||
hiddenimports.append('hwilib.devices.' + d)
|
||||
42
hwi.spec
Normal file
42
hwi.spec
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- mode: python -*-
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
block_cipher = None
|
||||
|
||||
binaries = []
|
||||
if platform.system() == 'Windows':
|
||||
binaries = [("c:/python3/libusb-1.0.dll", ".")]
|
||||
elif platform.system() == 'Linux':
|
||||
binaries = [("/lib/x86_64-linux-gnu/libusb-1.0.so.0", ".")]
|
||||
elif platform.system() == 'Darwin':
|
||||
find_brew_libusb_proc = subprocess.Popen(['brew', '--prefix', 'libusb'], stdout=subprocess.PIPE)
|
||||
libusb_path = find_brew_libusb_proc.communicate()[0]
|
||||
binaries = [(libusb_path.rstrip().decode() + "/lib/libusb-1.0.dylib", ".")]
|
||||
|
||||
a = Analysis(['hwi.py'],
|
||||
binaries=binaries,
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=['contrib/pyinstaller-hooks/'],
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='hwi',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
runtime_tmpdir=None,
|
||||
console=True )
|
||||
@ -2,14 +2,13 @@
|
||||
|
||||
# Hardware wallet interaction script
|
||||
|
||||
import glob
|
||||
import importlib
|
||||
|
||||
from .serializations import PSBT, Base64ToHex, HexToBase64, hash160
|
||||
from .base58 import get_xpub_fingerprint_as_id, get_xpub_fingerprint_hex, xpub_to_pub_hex
|
||||
from os.path import dirname, basename, isfile
|
||||
from .errors import NoPasswordError, UnavailableActionError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, UnknownDeviceError, BAD_ARGUMENT, NOT_IMPLEMENTED
|
||||
from .descriptor import Descriptor
|
||||
from .devices import __all__ as all_devs
|
||||
|
||||
# Get the client for the device
|
||||
def get_client(device_type, device_path, password=''):
|
||||
@ -32,11 +31,7 @@ def get_client(device_type, device_path, password=''):
|
||||
def enumerate(password=''):
|
||||
result = []
|
||||
|
||||
# Gets the module names of all the files in devices/
|
||||
files = glob.glob(dirname(__file__)+"/devices/*.py")
|
||||
modules = [ basename(f)[:-3] for f in files if isfile(f) and not f.endswith('__init__.py')]
|
||||
|
||||
for module in modules:
|
||||
for module in all_devs:
|
||||
try:
|
||||
imported_dev = importlib.import_module('.devices.' + module, __package__)
|
||||
result.extend(imported_dev.enumerate(password))
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
__all__ = [
|
||||
'trezor',
|
||||
'ledger',
|
||||
'keepkey',
|
||||
'digitalbitbox',
|
||||
'coldcard'
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user