1
0
Files
electrum/contrib/print_electrum_version.py
SomberNight 5f309e95c8 release.sh: don't hardcode ".0" suffix in APK_VERSION
does not work with current beta:
```
d142c5534f4da4a7f0a1f52676716908f674ff9e06b87f7b153384b161296eaf  /home/user/wspace/electrum/contrib/android/../../dist/Electrum-4.5.0.0-armeabi-v7a-release-unsigned.apk
+ mv dist/Electrum-4.5.0b0.0-armeabi-v7a-release-unsigned.apk dist/Electrum-4.5.0b0.0-armeabi-v7a-release.apk
mv: cannot stat 'dist/Electrum-4.5.0b0.0-armeabi-v7a-release-unsigned.apk': No such file or directory
```
2023-12-13 17:21:33 +00:00

34 lines
1.2 KiB
Python
Executable File

#!/usr/bin/python3
# For usage in shell, to get the version of electrum, without needing electrum installed.
# usage: ./print_electrum_version.py [<attr_name>]
#
# For example:
# $ VERSION=$("$CONTRIB"/print_electrum_version.py)
# $ VERSION=$("$CONTRIB"/print_electrum_version.py APK_VERSION)
# instead of
# $ VERSION=$(python3 -c "import electrum; print(electrum.version.ELECTRUM_VERSION)")
# $ VERSION=$(python3 -c "import electrum; print(electrum.version.APK_VERSION)")
import importlib.util
import os
import sys
if __name__ == '__main__':
if len(sys.argv) >= 2:
attr_name = sys.argv[1]
else:
attr_name = "ELECTRUM_VERSION"
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
version_file_path = os.path.join(project_root, "electrum", "version.py")
# load version.py; needlessly complicated alternative to "imp.load_source":
version_spec = importlib.util.spec_from_file_location('version', version_file_path)
version_module = version = importlib.util.module_from_spec(version_spec)
version_spec.loader.exec_module(version_module)
attr_val = getattr(version, attr_name)
print(attr_val, file=sys.stdout)