caveats: recommend Python .pth file instead.

This is better than PYTHONPATH as it doesn't mess with incompatible
versions of Python.

Closes Homebrew/homebrew#27138.
This commit is contained in:
Mike McQuaid 2014-03-08 12:56:15 +00:00
parent 9030c19418
commit d8ef8d4f82

View File

@ -46,17 +46,22 @@ class Caveats
end end
def python_caveats def python_caveats
return unless keg
return unless keg.python_site_packages_installed?
return if Formula["python"].installed?
site_packages = if f.keg_only? site_packages = if f.keg_only?
"#{f.opt_prefix}/lib/python2.7/site-packages" "#{f.opt_prefix}/lib/python2.7/site-packages"
else else
"#{HOMEBREW_PREFIX}/lib/python2.7/site-packages" "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"
end end
if keg and keg.python_site_packages_installed? \ dir = "~/Library/Python/2.7/lib/python/site-packages"
and !ENV['PYTHONPATH'].to_s.include? site_packages dir_path = Pathname.new(dir).expand_path
<<-EOS.undent file = "#{dir}/homebrew.pth"
Set PYTHONPATH if you need Python to find the installed site-packages: file_path = Pathname.new(file).expand_path
export PYTHONPATH=#{site_packages}:$PYTHONPATH if !file_path.readable? || !file_path.read.include?(site_packages)
EOS s = "If you need Python to find the installed site-packages:\n"
s += " mkdir -p #{dir}\n" unless dir_path.exist?
s += " echo '#{site_packages}' >> #{file}"
end end
end end