Skip to content

Commit

Permalink
bottle: delete .pyo files as with .pyc (Homebrew#382)
Browse files Browse the repository at this point in the history
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 Homebrew/homebrew-core#2125 (comment)
  • Loading branch information
lucafavatella authored and UniqMartin committed Jun 20, 2016
1 parent 29bfc4c commit c602210
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Library/Homebrew/keg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c602210

Please sign in to comment.