cleaner: remove pip direct_url.json

Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
Michael Cho 2024-03-07 18:27:26 -05:00
parent 3d948b7803
commit 4b5bcd39fd
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85

View File

@ -58,6 +58,7 @@ class Cleaner
end end
rewrite_shebangs rewrite_shebangs
remove_pip_direct_url
prune prune
end end
@ -163,6 +164,28 @@ class Cleaner
end end
end 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 end
require "extend/os/cleaner" require "extend/os/cleaner"