diff --git a/contrib/pyinstaller-hooks/hook-hwilib.devices.py b/contrib/pyinstaller-hooks/hook-hwilib.devices.py new file mode 100644 index 0000000..260d262 --- /dev/null +++ b/contrib/pyinstaller-hooks/hook-hwilib.devices.py @@ -0,0 +1,4 @@ +from hwilib.devices import __all__ +hiddenimports = [] +for d in __all__: + hiddenimports.append('hwilib.devices.' + d) diff --git a/hwi.spec b/hwi.spec new file mode 100644 index 0000000..049b96f --- /dev/null +++ b/hwi.spec @@ -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 ) diff --git a/hwilib/commands.py b/hwilib/commands.py index 002c3f1..f55ecb9 100644 --- a/hwilib/commands.py +++ b/hwilib/commands.py @@ -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)) diff --git a/hwilib/devices/__init__.py b/hwilib/devices/__init__.py index e69de29..a4f93f1 100644 --- a/hwilib/devices/__init__.py +++ b/hwilib/devices/__init__.py @@ -0,0 +1,7 @@ +__all__ = [ + 'trezor', + 'ledger', + 'keepkey', + 'digitalbitbox', + 'coldcard' +]