add extra env variable to support winget installation#4398
Open
dtrawins wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Windows entrypoint to initialize OPENVINO_TOKENIZERS_PATH_GENAI automatically when OVMS is deployed as an MSIX/winget package, by discovering the OpenVINO Tokenizers dependency package and deriving the DLL path from its installed location.
Changes:
- Added C++/WinRT package dependency inspection to locate the Tokenizers MSIX dependency.
- Set
OPENVINO_TOKENIZERS_PATH_GENAIbased on the dependency’s InstalledLocation at process startup. - Introduced a new WinRT header include to support the dependency query.
Comments suppressed due to low confidence (2)
src/main_windows.cpp:118
- This code uses C++/WinRT APIs (
Package::Current()...) but the thread apartment is never initialized (nowinrt::init_apartment()found). Without initialization, WinRT calls can fail and the env var will not be set even in packaged deployments.
try {
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::ApplicationModel::Package> deps =
winrt::Windows::ApplicationModel::Package::Current().Dependencies();
for (const winrt::Windows::ApplicationModel::Package& dep : deps) {
src/main_windows.cpp:123
- This unconditionally overwrites
OPENVINO_TOKENIZERS_PATH_GENAI, which can clobber a user- or admin-provided setting. Prefer only setting it when it is not already defined, and consider logging/handling a failure return fromSetEnvironmentVariableW.
SetEnvironmentVariableW(L"OPENVINO_TOKENIZERS_PATH_GENAI", dllPath.c_str());
DEBUG_LOG("OPENVINO_TOKENIZERS_PATH_GENAI initialized from package dependency.");
return;
| winrt::Windows::ApplicationModel::Package::Current().Dependencies(); | ||
| for (const winrt::Windows::ApplicationModel::Package& dep : deps) { | ||
| if (dep.Id().Name() == PACKAGE_NAME) { | ||
| const std::wstring dllPath = dep.InstalledLocation().Path().c_str() + std::wstring(TOKENIZERS_RELATIVE_PATH); |
| #include <windows.h> | ||
| #include <tchar.h> | ||
| #include <errors.h> | ||
| #include <winrt/Windows.ApplicationModel.h> |
Comment on lines
+112
to
+120
| constexpr wchar_t PACKAGE_NAME[] = L"Intel.OpenVINO.Tokenizers.2026.3.0.0"; | ||
| constexpr wchar_t TOKENIZERS_RELATIVE_PATH[] = L"\\runtime\\bin\\intel64\\Release\\openvino_tokenizers.dll"; | ||
|
|
||
| try { | ||
| winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::ApplicationModel::Package> deps = | ||
| winrt::Windows::ApplicationModel::Package::Current().Dependencies(); | ||
| for (const winrt::Windows::ApplicationModel::Package& dep : deps) { | ||
| if (dep.Id().Name() == PACKAGE_NAME) { | ||
| const std::wstring dllPath = dep.InstalledLocation().Path().c_str() + std::wstring(TOKENIZERS_RELATIVE_PATH); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 Summary
JIRA/Issue if applicable.
Describe the changes.
🧪 Checklist
``