From 4b5bcd39fd70539068df2a40fa2dd81bfe6b330c Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Thu, 7 Mar 2024 18:27:26 -0500 Subject: [PATCH] cleaner: remove pip direct_url.json Signed-off-by: Michael Cho --- Library/Homebrew/cleaner.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb index 66b5c8f4df..cf3e84586c 100644 --- a/Library/Homebrew/cleaner.rb +++ b/Library/Homebrew/cleaner.rb @@ -58,6 +58,7 @@ class Cleaner end rewrite_shebangs + remove_pip_direct_url prune end @@ -163,6 +164,28 @@ class Cleaner end end end + + # Remove non-reproducible pip direct_url.json which records the /tmp build directory + sig { void } + def remove_pip_direct_url + basepath = @formula.prefix.realpath + basepath.find do |path| + Find.prune if @formula.skip_clean?(path) + + next if path.directory? || path.symlink? + next if path.basename.to_s != "direct_url.json" + next if path.parent.extname != ".dist-info" + + odebug "Removing #{path}" + path.unlink + + record = path.parent/"RECORD" + next unless record.file? + + odebug "Modifying #{record}" + @formula.inreplace record, %r{^.*/direct_url\.json,.*$\n?}, "", false + end + end end require "extend/os/cleaner"