aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Favatella2016-06-21 00:22:58 +0100
committerMartin Afanasjew2016-06-21 01:22:58 +0200
commitc6022104f9df7fa1fc7bae596a770cdc073c8552 (patch)
tree5f34eed9a04377ec17eeeb2371d93620a5576f6a
parent29bfc4caa3f7dde97ad4fd62d7da0adededbeede (diff)
downloadbrew-c6022104f9df7fa1fc7bae596a770cdc073c8552.tar.bz2
bottle: delete .pyo files as with .pyc (#382)
This should make more bottles relocatable e.g. ansible. .pyo files are bytecode as .pyc files but optimized - [ref](https://www.python.org/dev/peps/pep-0488/) Ref https://github.com/Homebrew/homebrew-core/pull/2125#issuecomment-226987124
-rw-r--r--Library/Homebrew/keg.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 778d436a4..9adf657fe 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -396,7 +396,7 @@ class Keg
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 @@ class Keg
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