android build: enable asserts, and add sanity-check for it
Note that 0f541be6f1 added a warning log if asserts are disabled.
It is intentional that these two things are in separate files:
We always want to log that warning, even if someone is using electrum as a library.
However, in that latter case, I think it's fine not to sys.exit(), but leave the decision up to the library user.
Similar thinking when running from source: let's log the warning but don't sys.exit().
This commit is contained in:
@@ -179,8 +179,8 @@ RUN cd /opt \
|
|||||||
&& git remote add sombernight https://github.com/SomberNight/python-for-android \
|
&& git remote add sombernight https://github.com/SomberNight/python-for-android \
|
||||||
&& git remote add accumulator https://github.com/accumulator/python-for-android \
|
&& git remote add accumulator https://github.com/accumulator/python-for-android \
|
||||||
&& git fetch --all \
|
&& git fetch --all \
|
||||||
# commit: from branch accumulator/electrum_20210421d (note: careful with force-pushing! see #8162)
|
# commit: from branch sombernight/electrum_20210421d (note: careful with force-pushing! see #8162)
|
||||||
&& git checkout "3c2750795ba93aa1a3e513a13c2ea2ac5bddba17^{commit}" \
|
&& git checkout "ec82acf894822373ae88247658a233c77e76f879^{commit}" \
|
||||||
&& python3 -m pip install --no-build-isolation --no-dependencies --user -e .
|
&& python3 -m pip install --no-build-isolation --no-dependencies --user -e .
|
||||||
|
|
||||||
# build env vars
|
# build env vars
|
||||||
|
|||||||
16
run_electrum
16
run_electrum
@@ -44,8 +44,9 @@ script_dir = os.path.dirname(os.path.realpath(__file__))
|
|||||||
is_pyinstaller = getattr(sys, 'frozen', False)
|
is_pyinstaller = getattr(sys, 'frozen', False)
|
||||||
is_android = 'ANDROID_DATA' in os.environ
|
is_android = 'ANDROID_DATA' in os.environ
|
||||||
is_appimage = 'APPIMAGE' in os.environ
|
is_appimage = 'APPIMAGE' in os.environ
|
||||||
|
is_binary_distributable = is_pyinstaller or is_android or is_appimage
|
||||||
# is_local: unpacked tar.gz but not pip installed, or git clone
|
# is_local: unpacked tar.gz but not pip installed, or git clone
|
||||||
is_local = (not is_pyinstaller and not is_android and not is_appimage
|
is_local = (not is_binary_distributable
|
||||||
and os.path.exists(os.path.join(script_dir, "electrum.desktop")))
|
and os.path.exists(os.path.join(script_dir, "electrum.desktop")))
|
||||||
is_git_clone = is_local and os.path.exists(os.path.join(script_dir, ".git"))
|
is_git_clone = is_local and os.path.exists(os.path.join(script_dir, ".git"))
|
||||||
|
|
||||||
@@ -62,6 +63,19 @@ if is_pyinstaller:
|
|||||||
# causes ImportErrors and other runtime failures). (see #4072)
|
# causes ImportErrors and other runtime failures). (see #4072)
|
||||||
_file = open(sys.executable, 'rb')
|
_file = open(sys.executable, 'rb')
|
||||||
|
|
||||||
|
if is_binary_distributable:
|
||||||
|
# Ensure that asserts are enabled.
|
||||||
|
# Code *should not rely* on asserts being enabled. In particular, safety and security checks should
|
||||||
|
# always explicitly raise exceptions. However, this rule is mistakenly broken occasionally...
|
||||||
|
# In case we are a binary build, we know for a fact that we want the asserts, so enforce them.
|
||||||
|
# When running from source, defer to the user. (a warning is logged in __init__.py)
|
||||||
|
try:
|
||||||
|
assert False
|
||||||
|
except AssertionError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
sys.exit("Error: Running with asserts disabled, in a binary distributable! Please check build settings.")
|
||||||
|
|
||||||
|
|
||||||
def check_imports():
|
def check_imports():
|
||||||
# pure-python dependencies need to be imported here for pyinstaller
|
# pure-python dependencies need to be imported here for pyinstaller
|
||||||
|
|||||||
Reference in New Issue
Block a user