-
Notifications
You must be signed in to change notification settings - Fork 656
fix(win): Embed manifest in OIIO .exes to enable long path handling #5066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lgritz
merged 2 commits into
AcademySoftwareFoundation:main
from
nrusch:add_windows_exe_manifests
Mar 7, 2026
+139
−2
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
| <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
| <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
| <security> | ||
| <requestedPrivileges> | ||
| <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> | ||
| </requestedPrivileges> | ||
| </security> | ||
| </trustInfo> | ||
| <application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
| <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> | ||
| <ws2:longPathAware>true</ws2:longPathAware> | ||
| </windowsSettings> | ||
| </application> | ||
| </assembly> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // Resource script for OIIO EXEs. | ||
|
|
||
| // The value is invariant, so should be safe to hardcode, but we could replace | ||
| // 24 with `RT_MANIFEST` by adding `#include "winres.h"` first. | ||
| // Reference: https://learn.microsoft.com/en-us/windows/win32/menurc/user-defined-resource | ||
| 1 24 "oiio_exe.manifest" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """Helper script to detect system-level long path support on Windows. | ||
|
|
||
| Returns 0 if the long path support is enabled in the registry, or 1 otherwise. | ||
|
|
||
| Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#registry-setting-to-enable-long-paths | ||
| """ | ||
|
|
||
| # Copyright Contributors to the OpenImageIO project. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
|
||
| import sys | ||
| import winreg | ||
|
|
||
| _SUB_KEY = "SYSTEM\\CurrentControlSet\\Control\\FileSystem" | ||
| _VALUE_NAME = "LongPathsEnabled" | ||
|
|
||
|
|
||
| def main() -> int: | ||
| try: | ||
| with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, _SUB_KEY) as key: | ||
| reg_value, value_type = winreg.QueryValueEx(key, _VALUE_NAME) | ||
| except OSError: | ||
| # Key does not exist | ||
| return 1 | ||
|
|
||
| # It's vanishingly unlikely that someone would stuff some other value type | ||
| # in this key, but let's be paranoid. | ||
| if value_type != winreg.REG_DWORD: | ||
| return 1 | ||
|
|
||
| return int(reg_value != 1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """Test script for long path support in compiled Windows executables. | ||
|
|
||
| This script verifies that `oiiotool` can read paths longer than MAX_PATH (260) | ||
| characters on Windows. | ||
|
|
||
| Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation | ||
| """ | ||
|
|
||
| # Copyright Contributors to the OpenImageIO project. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
|
||
| import argparse | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| from uuid import uuid4 | ||
|
|
||
| _WINDOWS_MAX_PATH = 260 | ||
|
|
||
|
|
||
| def main(src_root: str, oiiotool_exe: str) -> int: | ||
| """ | ||
| Manufactures a long directory path within a temp. directory, copies a test | ||
| image to it, and ensures `oiiotool` can read it without erroring. | ||
| """ | ||
| if not os.path.isfile(oiiotool_exe): | ||
| print(f"ERROR: oiiotool path {oiiotool_exe!r} does not exist") | ||
| return 1 | ||
|
|
||
| test_image = "grid.tif" | ||
| src_image_path = os.path.join(src_root, "testsuite", "common", test_image) | ||
|
|
||
| with tempfile.TemporaryDirectory() as test_dir: | ||
| while len(test_dir) < _WINDOWS_MAX_PATH: | ||
| test_dir = os.path.join(test_dir, str(uuid4())) | ||
| os.makedirs(test_dir, exist_ok=True) | ||
|
|
||
| shutil.copy(src_image_path, test_dir) | ||
| test_image_path = os.path.join(test_dir, test_image) | ||
|
|
||
| print("Testing long image path:", test_image_path, flush=True) | ||
| result = subprocess.call([oiiotool_exe, test_image_path, "--printinfo"]) | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description="Windows long path test") | ||
| parser.add_argument("--source-root", required=True) | ||
| parser.add_argument("--oiiotool-path", required=True) | ||
| args = parser.parse_args() | ||
|
|
||
| sys.exit(main(args.source_root, args.oiiotool_path)) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I don't have a strong instinct for. The manifest resource ID isn't going to change, and this value hardcoding seems to be fairly commonplace from what I've found. I opted to avoid an
#includehere to start just because I don't know if that would have any other implications.