From d9e3b6143e6bd6eb7e6527520b1d909d07d1eb92 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 13 Jun 2023 18:59:46 +0000 Subject: [PATCH] fix: Ignore tempoary pyc.NNN files in wheels. We ignore pyc files most everywhere (because they aren't deterministic), but part of the pyc creation process involves creating temporary files named `*.pyc.NNN`. Though these are supposed to be temporary files nobody sees, they seem to get picked up by a glob somewhere, somehow. I'm unable to figure out how that is happening, but ignoring them in the glob expressions should also suffice. Fixes #1261 --- python/pip_install/repositories.bzl | 1 + python/pip_install/tools/wheel_installer/wheel_installer.py | 1 + python/repositories.bzl | 1 + 3 files changed, 3 insertions(+) diff --git a/python/pip_install/repositories.bzl b/python/pip_install/repositories.bzl index 2dd4a3724b..efe3bc72a0 100644 --- a/python/pip_install/repositories.bzl +++ b/python/pip_install/repositories.bzl @@ -106,6 +106,7 @@ py_library( # to avoid non-determinism following pip install's behavior. "**/*.py", "**/*.pyc", + "**/*.pyc.*", # During pyc creation, temp files named *.pyc.NNN are created "**/* *", "**/*.dist-info/RECORD", "BUILD", diff --git a/python/pip_install/tools/wheel_installer/wheel_installer.py b/python/pip_install/tools/wheel_installer/wheel_installer.py index 5a6f49bb5b..9b363c3068 100644 --- a/python/pip_install/tools/wheel_installer/wheel_installer.py +++ b/python/pip_install/tools/wheel_installer/wheel_installer.py @@ -226,6 +226,7 @@ def _generate_build_file_contents( "**/* *", "**/*.py", "**/*.pyc", + "**/*.pyc.*", # During pyc creation, temp files named *.pyc.NNNN are created # RECORD is known to contain sha256 checksums of files which might include the checksums # of generated files produced when wheels are installed. The file is ignored to avoid # Bazel caching issues. diff --git a/python/repositories.bzl b/python/repositories.bzl index e841e2888c..2352e22853 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -219,6 +219,7 @@ def _python_repository_impl(rctx): # the definition of this filegroup will change, and depending rules will get invalidated." # See https://github.com/bazelbuild/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them." "**/__pycache__/*.pyc", + "**/__pycache__/*.pyc.*", # During pyc creation, temp files named *.pyc.NNN are created "**/__pycache__/*.pyo", ]