From cc008de481bf1b67790d48b648d7c8207b9f50ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 27 Jun 2016 11:58:31 +0200 Subject: Add version number --- .gitignore | 1 + helpers/__init__.py | 13 +++++++++++++ music_sampler.py | 5 ++++- music_sampler.spec | 9 ++++++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 213ec35..0aa4e4c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ dist/ helpers/__pycache__/ __pycache__/ +.pyinstaller_commit diff --git a/helpers/__init__.py b/helpers/__init__.py index 0f819e7..f3e5967 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py @@ -9,6 +9,19 @@ def path(): path = os.path.dirname(os.path.realpath(__file__)) return path + "/../" +def parse_args(): + for arg in sys.argv: + if arg == "-v": + sys.argv.remove(arg) + + if getattr(sys, 'frozen', False): + f = open(path() + ".pyinstaller_commit", "r") + print(f.read(), end="") + f.close() + else: + print("option '-v' can only be used in bundled package") + sys.exit() + def duration_to_min_sec(duration): minutes = int(duration / 60) seconds = int(duration) % 60 diff --git a/music_sampler.py b/music_sampler.py index 7bd7513..fd5bd90 100644 --- a/music_sampler.py +++ b/music_sampler.py @@ -1,3 +1,7 @@ +import helpers + +helpers.parse_args() + import kivy kivy.require("1.9.1") from kivy.app import App @@ -9,7 +13,6 @@ from kivy.core.window import Window from kivy.lang import Builder from helpers.key import Key from helpers.mapping import Mapping -import helpers class KeyList(RelativeLayout): keylist = ListProperty([]) diff --git a/music_sampler.spec b/music_sampler.spec index ef949f2..7a885fd 100644 --- a/music_sampler.spec +++ b/music_sampler.spec @@ -1,14 +1,21 @@ # -*- mode: python -*- +import os from kivy.tools.packaging.pyinstaller_hooks import get_deps_minimal, hookspath, runtime_hooks excluded_and_hidden_modules = get_deps_minimal(video=None, camera=None, audio=None, clipboard=None, spelling=None) excluded_and_hidden_modules['hiddenimports'] += [ 'six', 'packaging', 'packaging.version', 'packaging.specifiers', 'packaging.requirements'] +commit_message = os.popen('git log -1 --format="%h %ci"').read() +pyinstaller_file = open(".pyinstaller_commit", "w") +pyinstaller_file.write(commit_message) +pyinstaller_file.close() + a = Analysis(['music_sampler.py'], binaries=None, datas=[ ('fonts/*', 'fonts'), - ('music_sampler.kv', '.') + ('music_sampler.kv', '.'), + ('.pyinstaller_commit', '.') ], hookspath=hookspath(), runtime_hooks=runtime_hooks(), -- cgit v1.2.3