diff --git a/addon/globalPlugins/MathCAT/MathCAT.py b/addon/globalPlugins/MathCAT/MathCAT.py index 62760fcc..388f103f 100644 --- a/addon/globalPlugins/MathCAT/MathCAT.py +++ b/addon/globalPlugins/MathCAT/MathCAT.py @@ -22,7 +22,7 @@ import winKernel import gui -from . import libmathcat_py as libmathcat +from ._libmathcat_loader import libmathcat from typing import Type from collections.abc import Generator, Callable from keyboardHandler import KeyboardInputGesture # navigation key strokes diff --git a/addon/globalPlugins/MathCAT/MathCATPreferences.py b/addon/globalPlugins/MathCAT/MathCATPreferences.py index 0012ccb0..4ba594a5 100644 --- a/addon/globalPlugins/MathCAT/MathCATPreferences.py +++ b/addon/globalPlugins/MathCAT/MathCATPreferences.py @@ -808,7 +808,7 @@ def writeUserPreferences() -> None: folder exists, and saves the preferences to disk. """ # Language is special because it is set elsewhere by SetPreference which overrides the user_prefs -- so set it here - from . import libmathcat_py as libmathcat + from ._libmathcat_loader import libmathcat try: libmathcat.SetPreference("Language", userPreferences["Speech"]["Language"]) diff --git a/addon/globalPlugins/MathCAT/_libmathcat_loader.py b/addon/globalPlugins/MathCAT/_libmathcat_loader.py new file mode 100644 index 00000000..88c25fea --- /dev/null +++ b/addon/globalPlugins/MathCAT/_libmathcat_loader.py @@ -0,0 +1,19 @@ +# -*- coding: UTF-8 -*- + +"""Loads the libmathcat_py extension module matching the running process's bitness. + +Both a 32-bit and a 64-bit build of libmathcat_py ship in this addon so a single +package works under both 32-bit and 64-bit NVDA. +""" + +import importlib.util +import os +import sys + +# checking for 64 vs 32-bit: https://docs.python.org/3/library/platform.html#cross-platform +_bitness = "x64" if sys.maxsize > 2**32 else "x86" +_pyd_path = os.path.join(os.path.dirname(__file__), f"libmathcat_py_{_bitness}.pyd") + +_spec = importlib.util.spec_from_file_location("libmathcat_py", _pyd_path) +libmathcat = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(libmathcat) diff --git a/addon/globalPlugins/MathCAT/libmathcat_py.pyd b/addon/globalPlugins/MathCAT/libmathcat_py.pyd deleted file mode 100644 index 9c1f2b1d..00000000 Binary files a/addon/globalPlugins/MathCAT/libmathcat_py.pyd and /dev/null differ diff --git a/addon/globalPlugins/MathCAT/libmathcat_py_x64.pyd b/addon/globalPlugins/MathCAT/libmathcat_py_x64.pyd new file mode 100644 index 00000000..852feca2 Binary files /dev/null and b/addon/globalPlugins/MathCAT/libmathcat_py_x64.pyd differ diff --git a/build-nvda-addon.sh b/build-nvda-addon.sh index c5c7c4fc..3c5cc86e 100644 --- a/build-nvda-addon.sh +++ b/build-nvda-addon.sh @@ -6,7 +6,7 @@ STFLAGS='-C linker=lld' PYO3_PYTHON=$YO3_PYTHON_32/python.exe STFLAGS="$STFLAGS" cargo build --target i686-pc-windows-msvc --release -cp target/i686-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py.pyd +cp target/i686-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py_x86.pyd # for testing cp target/i686-pc-windows-msvc/release/libmathcat_py.dll Example/libmathcat_py.pyd diff --git a/build64-nvda-addon.sh b/build64-nvda-addon.sh index 56bc30e7..6f8c4904 100644 --- a/build64-nvda-addon.sh +++ b/build64-nvda-addon.sh @@ -8,9 +8,9 @@ echo "before cargo build" PYO3_PYTHON=${PYO3_PYTHON_64}/python.exe STFLAGS="$STFLAGS" cargo build --target x86_64-pc-windows-msvc --release echo "after cargo build" -echo "before cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py.pyd" +echo "before cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py_x64.pyd" -cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py.pyd +cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll addon/globalPlugins/MathCAT/libmathcat_py_x64.pyd # for testing cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll Example/libmathcat_py.pyd diff --git a/buildVars.py b/buildVars.py index c35304d6..c3117ffa 100644 --- a/buildVars.py +++ b/buildVars.py @@ -44,7 +44,7 @@ def _(arg): # Documentation file name "addon_docFileName": "readme.html", # Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional) - "addon_minimumNVDAVersion": "2026.1", + "addon_minimumNVDAVersion": "2025.1", # Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version) "addon_lastTestedNVDAVersion": "2026.1", # Add-on update channel (default is None, denoting stable releases,