diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 778d436a4fd7c..9adf657fed79c 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -396,7 +396,7 @@ def optlink(mode = OpenStruct.new) end def delete_pyc_files! - find { |pn| pn.delete if pn.extname == ".pyc" } + find { |pn| pn.delete if %w[.pyc .pyo].include?(pn.extname) } end private @@ -483,9 +483,10 @@ def link_dir(relative_dir, mode) if src.symlink? || src.file? Find.prune if File.basename(src) == ".DS_Store" Find.prune if src.realpath == dst - # Don't link pyc files because Python overwrites these cached object - # files and next time brew wants to link, the pyc file is in the way. - if src.extname == ".pyc" && src.to_s =~ /site-packages/ + # Don't link pyc or pyo files because Python overwrites these + # cached object files and next time brew wants to link, the + # file is in the way. + if %w[.pyc .pyo].include?(src.extname) && src.to_s.include?("/site-packages/") Find.prune end