-
Notifications
You must be signed in to change notification settings - Fork 202
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
Windows Python 3.8+ os.add_dll_directory search order is defined as unspecified #2859
Comments
@seando-adsk is this something that would require USD changes or could it be taken care of from the Maya USD Plugin Side? |
Thanks for the information about
Would you be able to try this on your machines with the problem and see if it fixes it. Sean |
@seando-adsk That was the fix we came up with as well, and it seems to work. Or (more precisely) It doesn't immediately break :) @santosd Even if this falls mostly on the Maya side to "fix"... This error is so esoteric that I think it would be a good idea to update |
@tbttfox Would you be able to submit a pull-request with the fix to the mod file? I didn't see a CLA on file for your company, so please have a look at CONTRIBUTING.md. As for making a change to |
Issue synced internally to EMSUSD-751 |
Oh, I'm sorry. I forgot to close this issue when my PR got merged. |
Describe the bug
Random users across our studio would get this dll error when running
from pxr import Tf
. Unfortunately, this was machine specific as far as we could tell. Identical setups on different machines would give different results.Steps to reproduce
I don't think it's possible to reproduce. See Additional Context
Expected behavior
No DLL Error
Specs (if applicable):
Additional context
We found that USD looks at the system's
PATH
variable to load its dll's on python 3.8+ here:https://github.com/PixarAnimationStudios/USD/blob/release/pxr/base/tf/__init__.py#L47
So we started chasing the DLL's, and the breaking machines were loading Bifrost's usd dll's before maya-usd's. This seemed very strange because maya-usd came before Bifrost in the
PATH
, and it wasn't happening on other machines.On a hunch, we checked the cpython source for
os.add_dll_directory
, which ends up calling this function:https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-adddlldirectory
And, oh boy, is there a doozy in those docs:
That says to me, that the paths added to the dll search are not necessarily searched in order, and without knowing the internal Windows DLL search mechanism, we apparently can't know that order.
Proposed solution
We don't need to search the entire
PATH
for libraries when we know exactly where they are. This is easily accomplished by appending toPXR_USD_WINDOWS_DLL_PATH
instead ofPATH
inmodules/mayaUSD.mod.template
Even if you figure out some other reason for this err, I would still recommend doing this.
I don't know about
modules/alUSD_Win.mod.template
ormodules/pxrUSD_Win.mod.template
though. Somebody with more experience should chime in.The text was updated successfully, but these errors were encountered: