Skip to content

Commit

Permalink
fix: make windows ignore pycs in runtime (#1715)
Browse files Browse the repository at this point in the history
The downloaded runtimes don't contain pyc files, which means Python
tries to create them at runtime, and thus the set of files in the
runtime changes. This normally just silently affects cache hits, but on
Windows can result is errors. This is because Windows has stricter file
access semantics (e.g. a file can't be deleted if its still opened) and
the way Python programs are built involves a step to zip everything up
(which then requires the pyc to exist to be put into the zip file).

To fix, always ignore pyc files for Windows hosts. This should prevent
those files from being picked up by the glob and being considered part
of the runtime.

Co-authored-by: aignas <240938+aignas@users.noreply.github.com>
  • Loading branch information
rickeylev and aignas authored Jan 23, 2024
1 parent ed8bce9 commit a64e55b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ A brief description of the categories of changes:

### Changed

* (toolchains) Windows hosts always ignore pyc files in the downloaded runtimes.
This fixes issues due to pyc files being created at runtime and affecting the
definition of what files were considered part of the runtime.

### Fixed

### Added
Expand Down
2 changes: 1 addition & 1 deletion python/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _python_repository_impl(rctx):
"**/__pycache__/*.pyc.*", # During pyc creation, temp files named *.pyc.NNN are created
]

if rctx.attr.ignore_root_user_error:
if rctx.attr.ignore_root_user_error or "windows" in rctx.os.name:
glob_exclude += [
# These pycache files are created on first use of the associated python files.
# Exclude them from the glob because otherwise between the first time and second time a python toolchain is used,"
Expand Down

0 comments on commit a64e55b

Please sign in to comment.