From 40a81de2ad7a6a07e5bf200ffe81a3b52d1878af Mon Sep 17 00:00:00 2001 From: VALLONGOL Date: Mon, 5 May 2025 16:03:03 +0200 Subject: [PATCH] add version --- .gitignore | 3 ++- GitUtility.spec | 41 ++++++++++++++++++++++++++++++------ gitutility/app.py | 20 ++++++++++++++++-- gitutility/gui/main_frame.py | 1 - 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 6aaffa4..e698cab 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ _build/ *.old # Python cache files __pycache__/ -*.py[cod] \ No newline at end of file +*.py[cod] +_version.py \ No newline at end of file diff --git a/GitUtility.spec b/GitUtility.spec index fef37a4..73a32ea 100644 --- a/GitUtility.spec +++ b/GitUtility.spec @@ -2,16 +2,45 @@ block_cipher = None -a = Analysis(scripts=['C:\\src\\____GitProjects\\GitUtility\\GitUtility.py'], pathex=['C:\\src\\____GitProjects\\GitUtility'], binaries=[], datas=[('C:\\src\\____GitProjects\\GitUtility\\git_svn_sync.ini', '.')], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=None, noarchive=False,) +import os +a = Analysis(scripts=['gitutility\\__main__.py'], + pathex=['gitutility'], + binaries=[], + datas=[('C:\\src\\____GitProjects\\GitUtility\\git_svn_sync.ini', '.')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=None, + noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=None) -exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='GitUtility', +exe = EXE(pyz, + a.scripts, + [], # Binaries/Datas usually handled by Analysis/COLLECT + exclude_binaries=True, # Let COLLECT handle binaries in one-dir + name='GitUtility', debug=False, bootloader_ignore_signals=False, strip=False, - upx=True, - upx_exclude=[], + upx=True, # Use UPX based on config runtime_tmpdir=None, - console=False,) -coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='GitUtility',) + console=False, # Set console based on GUI checkbox + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon='GitUtility.ico') + +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, # Match UPX setting + upx_exclude=[], + name='GitUtility') diff --git a/gitutility/app.py b/gitutility/app.py index 32eb325..97368be 100644 --- a/gitutility/app.py +++ b/gitutility/app.py @@ -55,7 +55,23 @@ from gitutility.async_tasks.async_result_handler import ( AsyncResultHandler, ) # Result processor -# ---<<< FINE MODIFICA IMPORT >>>--- +# --- Import Version Info FOR THE WRAPPER ITSELF --- +try: + # Use absolute import based on package name + from gitutility import _version as wrapper_version + WRAPPER_APP_VERSION_STRING = f"{wrapper_version.__version__} ({wrapper_version.GIT_BRANCH}/{wrapper_version.GIT_COMMIT_HASH[:7]})" + WRAPPER_BUILD_INFO = f"Wrapper Built: {wrapper_version.BUILD_TIMESTAMP}" +except ImportError: + # This might happen if you run the wrapper directly from source + # without generating its _version.py first (if you use that approach for the wrapper itself) + WRAPPER_APP_VERSION_STRING = "(Dev Wrapper)" + WRAPPER_BUILD_INFO = "Wrapper build time unknown" + +# --- Constants for Version Generation --- +DEFAULT_VERSION = "0.0.0+unknown" +DEFAULT_COMMIT = "Unknown" +DEFAULT_BRANCH = "Unknown" +# --- End Constants --- class GitSvnSyncApp: @@ -80,7 +96,7 @@ class GitSvnSyncApp: master (tk.Tk): The main Tkinter root window. """ self.master: tk.Tk = master - master.title("Git Utility (Bundle & Remote Manager)") + master.title(f"Git Utility (Bundle & Remote Manager) - {WRAPPER_APP_VERSION_STRING}") # Define behavior on window close button press master.protocol("WM_DELETE_WINDOW", self.on_closing) diff --git a/gitutility/gui/main_frame.py b/gitutility/gui/main_frame.py index bb64a8d..4479e5c 100644 --- a/gitutility/gui/main_frame.py +++ b/gitutility/gui/main_frame.py @@ -37,7 +37,6 @@ except ImportError: # Non importiamo più classi di Dialog, Editor, Viewer qui perché sono in file separati # Non importiamo moduli di logica (ActionHandler, GitCommands, etc.) - class MainFrame(ttk.Frame): """ The main application frame, containing the profile management bar,