fix: windows drive letters remap to unc paths#2104
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2104 +/- ##
==========================================
+ Coverage 60.95% 61.02% +0.06%
==========================================
Files 164 164
Lines 20629 20683 +54
Branches 3591 3606 +15
==========================================
+ Hits 12575 12621 +46
- Misses 7181 7182 +1
- Partials 873 880 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ae4aeb2 to
92b2b07
Compare
92b2b07 to
1681466
Compare
|
@maxnbk What's the relationship to #1856? During the TSC, @instinct-vfx said that the expected default behavior is that the style should stay consistent based on how the repo was configured? |
|
Can you please look at #1856. There are a few other places that realpath needs to be replaced. |
|
I'll take a look and see what else needs resolving. I may have to add some more tests to find all the edge-cases. Goal is to incorporate all solutions from all mismatched PRs, as I think there were approximately 3 all trying to solve the same problem with partial/incomplete solutions, and nobody got all corners. Evidently that extends to me, so I'll re-evaluate and see what I need to do to extend. |
…is remapped by rez to a UNC path Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…repository filesystem to ensure its consumption Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…-compatible symlink/junction-point resolution behavior Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ion-behavior intended to produce realpath-like behavior Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…support in optional symlink-resolution for windows Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ath-aware. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…d network windows path styles Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…ation Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
1681466 to
7eb40dc
Compare
…migration points Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…s as needed by py3.8+ realpath changes Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…lization, not for opening/storing/passing Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…roper use of canonical_path vs real_path in resolved_context Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
7eb40dc to
a561892
Compare
…orm-specific symlink resolution Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…via resolved_context Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
…stead. Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
a561892 to
29a15fe
Compare
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
|
@JeanChristopheMorinPerso Looks like this didn't get merged into the 3.4.0. What can we do to get this out there? |
|
Hey @cfxegbert, this was intentional. We had a few more questions to answer and decided to push this to a follow up release. We are planning to do a 3.4.1 release soon-ish to get this PR out. When I reviewed the PR, I noticed that |
Closes #2045 and #1438 .
Partial but not complete fix for #1909 (Intentional, I feel that the work that was occurring in the gitbash PR would ultimately resolve this behavior?) .
Explanations:
os.path.realpathon Python 3.8+ Windows silently expands mapped drive letters to their underlying UNC paths. Becausecanonical_pathcallsrealpath,FileSystemPackageRepositorywas storing a UNCself.locationeven when the caller supplied a drive-letter path. This causedmake_resource_handle, which does a raw string comparison, to raiseResourceErroron every drive-letter handle against a UNC-stored repository.The fix:
On Windows,
canonical_pathnow usesos.path.abspathinstead ofos.path.realpath. This preserves path style (drive-letter stays drive-letter, UNC stays UNC) and restores the pre-3.8 normalization behavior without a network-resolution side-effect. Amake_resource_handleoverride is also added to thefilesystemplugin to handle residual case or separator mismatches viacanonical_path.Extension of work:
A
resolve_links_on_windowsconfig flag (defaultFalse) has been added for sites that need some form of symlink/junction resolution on Windows. When enabled, a purpose-built_windows_realpathwalks components of the path usingos.readlink, resolving real symlinks without actually touching the drive root, in order to avoid the UNC-expansion side-effect entirely. Long-path support (\\?\prefix handling) is included, with the relevant test skipped on hosts that do not haveLongPathsEnabled=1in the registry. Note: I'm aware that we need to move off of the winreg module, but since we have it for now, might as well use it.Testing:
This was tested against an actual Drive-letter-map-with-matching-UNC-network-share .
====EDIT====
This PR has been extended with a broader
real_pathmigration.real_path()helper - A new utility function infilesystem.pythat replacesos.path.realpathat all call sites where path-style stability is required.On Windows, it is delegated to
os.path.abspathto preserve the drive-letter style.On all other platforms, it is delegated to
os.path.realpathto preserve symlink resolution.Importantly, no config-flag is required - the correct behavior is derived from the OS, not user preference.
canonical_pathfrom the original PR slice now callsreal_pathinternally.Call-site migration - All non-test
os.path.realpathcode that touched stored, serialized, or compared paths have been updated:filesystem.py-canonical_path,is_subdirectoryresolved_context.py-_adjust_variant_for_bundlingserialise.py-open_file_for_write,load_from_filesuite.py-Suite.save,Suite.loadsystem.py -rez_bin_pathrezplugins/build_system/cmake.py- also corrects a pre-existing dead-code bug (os.path.abspathused as a truthiness check whereos.path.isabswas intended)utils/py_dist.py- egg-to-rez file path comparisons and copy destinationsRelationship to prior work - Several earlier attempts addressed this problem class but were either incomplete/partial, lacked tests, or relied on opt-in config flags:
====END EDIT====
Disclosure:
This PR was AI-assisted with Claude Code, Sonnet 4.6, primarily for diagnostics, logic-tracing, documentation and edge-case verification.