From b5bb0ca9e188f96abbac002da1bff78fd497d30f Mon Sep 17 00:00:00 2001 From: Felix Mallinder Date: Wed, 26 Aug 2026 11:02:17 +0100 Subject: [PATCH 1/3] added python version thank god for pythonnet --- .../Python/src/python_toolkit/bhom/__init__.py | 5 ++++- .../src/python_toolkit/bhom/installer_info.py | 15 +++++++++++++++ .../bhom_tkinter/bhom_window_shell.py | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Python_Engine/Python/src/python_toolkit/bhom/installer_info.py diff --git a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py index 4933adf..8519de9 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py +++ b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py @@ -6,10 +6,12 @@ import tempfile import importlib.metadata +from .installer_info import INSTALLER_INFO + BHOM_LOG_FOLDER = Path(path.expandvars("%PROGRAMDATA%/BHoM/Logs")) TEMP_LOG_FOLDER = Path(tempfile.gettempdir()) / "BHoM" / "Logs" TOOLKIT_NAME = "Python_Toolkit" -BHOM_VERSION = importlib.metadata.version("python_toolkit") +BHOM_VERSION = INSTALLER_INFO["Version"] #Environment variable that if set disables BHoM analytics logging. DISABLE_ANALYTICS = os.environ.get("DISABLE_BHOM_ANALYTICS", None) @@ -33,3 +35,4 @@ BHOM_LOG_FOLDER.mkdir(exist_ok=True, parents=True) + diff --git a/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py new file mode 100644 index 0000000..21ce80e --- /dev/null +++ b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py @@ -0,0 +1,15 @@ +import clr +import sys +import json + +#append assemblies dir +sys.path.append("C:\\ProgramData\\BHoM\\Assemblies") + +#add reference to the BHoM_UI assembly +clr.AddReference("UI_Engine") +clr.AddReference("Serialiser_Engine") + +from BH.Engine.UI import Query +from BH.Engine.Serialiser import Convert + +INSTALLER_INFO = json.loads(Convert.ToJson(Query.Information())) \ No newline at end of file diff --git a/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py b/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py index 0b922bb..25c6d3a 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py +++ b/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py @@ -12,6 +12,8 @@ from python_toolkit.bhom_tkinter.widgets.button import Button from python_toolkit.bhom_tkinter.theming.theme import ThemeManager +from python_toolkit.bhom import BHOM_VERSION + class BHoMWindowShell: """Shared themed window chrome for BHoM Tk root and Toplevel windows.""" @@ -323,7 +325,7 @@ def _build_banner(self, parent: ttk.Frame, title: str, logo_path: Optional[Path] # Subtitle subtitle_label = Label( text_container, - text="powered by BHoM", + text=f"powered by BHoM (v{BHOM_VERSION})", style="Caption.TLabel" ) subtitle_label.pack(anchor="w") From c244b7c82e7e1afac94fc802ff215a6ca8987752 Mon Sep 17 00:00:00 2001 From: Tom Kingstone Date: Wed, 26 Aug 2026 13:59:54 +0100 Subject: [PATCH 2/3] add pythonnet as a dependency and make sure that c# is only called in windows --- Python_Engine/Python/pyproject.toml | 1 + Python_Engine/Python/src/python_toolkit/bhom/__init__.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Python_Engine/Python/pyproject.toml b/Python_Engine/Python/pyproject.toml index 6a0be4e..6db0bd6 100644 --- a/Python_Engine/Python/pyproject.toml +++ b/Python_Engine/Python/pyproject.toml @@ -16,6 +16,7 @@ dependencies = [ "pytest-cov>=6.0.0", "pytest-order", "virtualenv", + "pythonnet", ] [urls] diff --git a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py index 8519de9..e3ab0b2 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py +++ b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py @@ -6,7 +6,10 @@ import tempfile import importlib.metadata -from .installer_info import INSTALLER_INFO +if os.name == 'nt': + from .installer_info import INSTALLER_INFO +else: + INSTALLER_INFO = {"Version": importlib.metadata.version("python_toolkit")} BHOM_LOG_FOLDER = Path(path.expandvars("%PROGRAMDATA%/BHoM/Logs")) TEMP_LOG_FOLDER = Path(tempfile.gettempdir()) / "BHoM" / "Logs" From 873e88eb0667959373078c6addb2b851412792d1 Mon Sep 17 00:00:00 2001 From: Tom Kingstone Date: Wed, 26 Aug 2026 15:28:08 +0100 Subject: [PATCH 3/3] make bhom path directory agnostic --- .../Python/src/python_toolkit/bhom/installer_info.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py index 21ce80e..10f1b76 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py +++ b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py @@ -1,11 +1,13 @@ -import clr +import os import sys import json +import clr + #append assemblies dir -sys.path.append("C:\\ProgramData\\BHoM\\Assemblies") +sys.path.append(os.path.expandvars("%ProgramData%\\BHoM\\Assemblies")) -#add reference to the BHoM_UI assembly +#add required CLR references (dotnet dlls) clr.AddReference("UI_Engine") clr.AddReference("Serialiser_Engine")