Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions news/win32_version_lookup.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a flaky error on Windows 2022 when looking up the win32 version during
site initialization by retrying the lookup
([#3721](https://github.com/bazel-contrib/rules_python/issues/3721)).
10 changes: 9 additions & 1 deletion python/private/site_init_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ def _get_windows_path_with_unc_prefix(path):
# Related doc: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later
import platform

if platform.win32_ver()[1] >= "10.0.14393":
win32_version = None
# Windows 2022 with Python 3.12.8 gives flakey errors, so try a couple times.
for _ in range(3):
try:
win32_version = platform.win32_ver()[1]
break
except (ValueError, KeyError):
pass
if win32_version and win32_version >= "10.0.14393":
return path
Comment thread
rickeylev marked this conversation as resolved.

# import sysconfig only now to maintain python 2.6 compatibility
Expand Down