Skip to content

Commit dc4991e

Browse files
committed
Handle manual specification of cx_Freeze packages required
o Report problems, when Paper Wallet support is not available
1 parent 64eb447 commit dc4991e

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ installer: $(INSTALLER)
168168

169169
dmg: build-deps app-dmg-valid
170170
msi: build-deps dist/slip39-$(VERSION)-win64.msi
171+
exe: build-deps build/exe.$(CXFREEZE_EXT)/SLIP-39.exe
171172
app: build-deps dist/SLIP-39.app
172173

173174
app-packages: app-zip-valid app-dmg-valid app-pkg-valid

setup.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
import glob
44
import fnmatch
55

6+
7+
#
8+
# All platforms
9+
#
10+
HERE = os.path.dirname( os.path.abspath( __file__ ))
11+
12+
install_requires = open( os.path.join( HERE, "requirements.txt" )).readlines()
13+
tests_require = open( os.path.join( HERE, "requirements-tests.txt" )).readlines()
14+
extras_require = {
15+
option: open( os.path.join( HERE, f"requirements-{option}.txt" )).readlines()
16+
for option in [
17+
'gui', # slip39[gui]: Support PySimpleGUI/tkinter Graphical UI App
18+
'dev', # slip39[dev]: All modules to support development
19+
'serial', # slip39[serial]: Support serial I/O of generated wallet data
20+
'wallet', # slip39[wallet]: Paper Wallet and BIP-38/Ethereum wallet encryption
21+
]
22+
}
23+
624
Executable = None
725
if sys.platform == 'win32':
826
# We use cx_Freeze for executable/installer packaging on Windows, only, for now.
@@ -60,7 +78,9 @@
6078
)
6179

6280
build_exe_options = dict(
63-
packages = [],
81+
packages = [
82+
'eth_account', 'Crypto', 'hdwallet', 'shamir_mnemonic', 'cytoolz', 'eth_hash',
83+
],
6484
excludes = [],
6585
include_msvcr = True,
6686
)
@@ -115,12 +135,6 @@
115135
)
116136
'''
117137

118-
119-
#
120-
# All platforms
121-
#
122-
HERE = os.path.dirname( os.path.abspath( __file__ ))
123-
124138
# Must work if setup.py is run in the source distribution context, or from
125139
# within the packaged distribution directory.
126140
__version__ = None
@@ -140,18 +154,6 @@
140154
'console_scripts': console_scripts,
141155
}
142156

143-
install_requires = open( os.path.join( HERE, "requirements.txt" )).readlines()
144-
tests_require = open( os.path.join( HERE, "requirements-tests.txt" )).readlines()
145-
extras_require = {
146-
option: open( os.path.join( HERE, f"requirements-{option}.txt" )).readlines()
147-
for option in [
148-
'gui', # slip39[gui]: Support PySimpleGUI/tkinter Graphical UI App
149-
'dev', # slip39[dev]: All modules to support development
150-
'serial', # slip39[serial]: Support serial I/O of generated wallet data
151-
'wallet', # slip39[wallet]: Paper Wallet and BIP-38/Ethereum wallet encryption
152-
]
153-
}
154-
155157
package_dir = {
156158
"slip39": "./slip39",
157159
"slip39.layout": "./slip39/layout",

slip39/api.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import math
88
import re
99
import secrets
10+
import warnings
1011

1112
from functools import wraps
1213
from collections import namedtuple
@@ -17,30 +18,48 @@
1718
import hdwallet
1819
from hdwallet import cryptocurrencies
1920

21+
log = logging.getLogger( __package__ )
22+
2023
# Support for private key encryption via BIP-38 and Ethereum JSON wallet is optional; pip install slip39[wallet]
24+
paper_wallet_issues = []
2125
try:
2226
from Crypto.Cipher import AES
2327
from Crypto.Protocol.KDF import scrypt
24-
except ImportError:
28+
except ImportError as exc:
2529
AES = None
2630
scrypt = None
31+
message = f"Unable to support Paper Wallet output: {exc}"
32+
warnings.warn( message, ImportWarning )
33+
log.warning( message )
34+
if log.isEnabledFor( logging.DEBUG ):
35+
log.exception( message )
36+
paper_wallet_issues.append( message )
37+
2738
try:
2839
import eth_account
29-
except ImportError:
40+
except ImportError as exc:
3041
eth_account = None
42+
message = f"Unable to support Paper Wallet output: {exc}"
43+
warnings.warn( message, ImportWarning )
44+
log.warning( message )
45+
if log.isEnabledFor( logging.DEBUG ):
46+
log.exception( message )
47+
paper_wallet_issues.append( message )
3148

3249
from .defaults import BITS_DEFAULT, BITS, MNEM_ROWS_COLS, GROUP_REQUIRED_RATIO, CRYPTO_PATHS
3350
from .util import ordinal
3451

3552

3653
RANDOM_BYTES = secrets.token_bytes
3754

38-
log = logging.getLogger( __package__ )
3955

4056

4157
def paper_wallet_available():
4258
"""Determine if encrypted BIP-38 and Ethereum JSON Paper Wallets are available."""
43-
return AES and scrypt and eth_account
59+
available = AES and scrypt and eth_account
60+
if not available:
61+
log.warning( f"Paper Wallets unavalailable: {', '.join( paper_wallet_issues )}" )
62+
return available
4463

4564

4665
def path_edit(

0 commit comments

Comments
 (0)