building: attempt to preserve parent directories for pywin32 extensions #7627
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.
Attempt to preserve the parent directories for
pywin32
extensions that originate fromwin32
andpythonwin
directories, rather than collecting them to the top-level application directory (which happens by default because those directories are added tosys.path
bypywin32.pth
). This is achieved by post-processing thebinaries
TOC at the end of the analysis process.This brings us closer to the original package layout, and allows us to remove a
pywin32
-specific hack from binary dependency analysis, where we earlier had to force collection of dependent binaries from thepythonwin
directory to the top-level directory (so that an extension from that directory, discovered via modulegraph, and dependent extension from that directory, discovered via binary dependency scanner, ended up in the same place).With a similar post-processing step, we also attempt to mitigate the issues caused by Anaconda
pywin32
package that installs three copies ofpywintypes3X.dll
andpythoncom3X.dll
in different locations, all of which are visible to us. So we have no control over which one we collect, which is problematic because we expect the copy to end up inpywin32_system32
directory. But with post-processing, we can bend the reality to our will, and divert those two files into desired destination directory. See #7624 (comment).Our
pywin32
extension import tests now all seem to pass also under Anaconda environments with Anacondapywin32
package installed.