From d8ef8d4f82417459af359109d33d2d2a4e1cb693 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 8 Mar 2014 12:56:15 +0000 Subject: [PATCH] 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. --- Library/Homebrew/caveats.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index 75746a8d23..26cb4cee40 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -46,17 +46,22 @@ class Caveats end def python_caveats + return unless keg + return unless keg.python_site_packages_installed? + return if Formula["python"].installed? site_packages = if f.keg_only? "#{f.opt_prefix}/lib/python2.7/site-packages" else "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages" end - if keg and keg.python_site_packages_installed? \ - and !ENV['PYTHONPATH'].to_s.include? site_packages - <<-EOS.undent - Set PYTHONPATH if you need Python to find the installed site-packages: - export PYTHONPATH=#{site_packages}:$PYTHONPATH - EOS + dir = "~/Library/Python/2.7/lib/python/site-packages" + dir_path = Pathname.new(dir).expand_path + file = "#{dir}/homebrew.pth" + file_path = Pathname.new(file).expand_path + if !file_path.readable? || !file_path.read.include?(site_packages) + 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