From 0e8db0155a02eed5bb3f3ecd90e23c5dd49fbec0 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Thu, 22 Aug 2024 19:19:17 -0400 Subject: [PATCH] language/python: avoid modifying all Python symlinks Homebrew Python will always have a realpath in HOMEBREW_CELLAR. Instead, check if the symlink target points to HOMEBREW_CELLAR. --- Library/Homebrew/language/python.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 3f97088eb1..7a9e0cbc76 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -330,8 +330,9 @@ module Language # Robustify symlinks to survive python patch upgrades @venv_root.find do |f| next unless f.symlink? - next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR + next unless f.readlink.expand_path.to_s.start_with? HOMEBREW_CELLAR + rp = f.realpath.to_s version = rp.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}o version = "@#{version.captures.first}" unless version.nil?