Skip to content

Conversation

GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Sep 19, 2025

Summary

When installing ExecuTorch from a wheel on Windows, the native pybinding extension DLL fails to load (#14443). This is because it's not on the search path. From a quick Google search, it seems like the recommended way to handle this is to call os.add_dll_directory prior to loading the extension.

I tested this locally by installing from wheel in a clean env and then patching the installed copy in site-packages. With this change, I was able to import executorch.extension.pybindings.portable_lib. I also ran the XNNPACK add op tests as a sanity check, which use pybindings.

Copy link

pytorch-bot bot commented Sep 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/14446

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures

As of commit b3933d8 with merge base 90ee347 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 19, 2025
@GregoryComer GregoryComer added release notes: none Do not include this in the release notes ciflow/binaries ciflow/binaries/all Release PRs with this label will build wheels for all python versions labels Sep 19, 2025
@GregoryComer GregoryComer changed the title Add pybind extension to the dll search path on Windows Add pybind extension to the DLL search path on Windows Sep 19, 2025
@GregoryComer GregoryComer marked this pull request as ready for review September 19, 2025 19:42

# Update the DLL search path on Windows. This is the recommended way to handle native
# extensions.
if sys.platform == "win32":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if sys.platform.startswith("win"):

so that it can catch "win64" and "windows"

Copy link
Member Author

@GregoryComer GregoryComer Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win32 is actually the stable value for sys.platform for both 32-bit and 64-bit Windows builds. I'm happy to change it, though it seems like direct comparison to "win32" is the idiomatic appoach.

@GregoryComer GregoryComer merged commit b1aed62 into pytorch:main Sep 22, 2025
154 of 158 checks passed
@GregoryComer
Copy link
Member Author

@pytorchbot cherry-pick --onto release/1.0 -c fixnewfeature

pytorchbot pushed a commit that referenced this pull request Sep 22, 2025
### Summary
When installing ExecuTorch from a wheel on Windows, the native pybinding
extension DLL fails to load
(#14443). This is because
it's not on the search path. From a quick Google search, it seems like
the recommended way to handle this is to call `os.add_dll_directory`
prior to loading the extension.

I tested this locally by installing from wheel in a clean env and then
patching the installed copy in site-packages. With this change, I was
able to import executorch.extension.pybindings.portable_lib. I also ran
the XNNPACK add op tests as a sanity check, which use pybindings.

(cherry picked from commit b1aed62)
@pytorchbot
Copy link
Collaborator

Cherry picking #14446

The cherry pick PR is at #14469 and it is recommended to link a fixnewfeature cherry pick PR with an issue. The following tracker issues are updated:

Details for Dev Infra team Raised by workflow job

StrycekSimon pushed a commit to nxp-upstream/executorch that referenced this pull request Sep 23, 2025
### Summary
When installing ExecuTorch from a wheel on Windows, the native pybinding
extension DLL fails to load
(pytorch#14443). This is because
it's not on the search path. From a quick Google search, it seems like
the recommended way to handle this is to call `os.add_dll_directory`
prior to loading the extension.

I tested this locally by installing from wheel in a clean env and then
patching the installed copy in site-packages. With this change, I was
able to import executorch.extension.pybindings.portable_lib. I also ran
the XNNPACK add op tests as a sanity check, which use pybindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries/all Release PRs with this label will build wheels for all python versions ciflow/binaries CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants