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"