aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorTim D. Smith2015-04-08 12:56:32 -0700
committerTim D. Smith2015-04-09 00:42:43 -0700
commitde3d496c31c892d773e66c969a9c5b9c796743d3 (patch)
tree261e1b878d78e837a4e2a831674e64a41c6f492f /Library/Homebrew
parenta32fd2c27399b60bad00aef6788bf45729f341f4 (diff)
downloadhomebrew-de3d496c31c892d773e66c969a9c5b9c796743d3.tar.bz2
Keep Homebrew site-packages in sys.path during brew test
Formulas that build python things and which are tested with system Python will encounter test failures unless system Python is configured to add Homebrew's site-packages to sys.path. This change makes sure that configuration is performed in the test environment. Both lines are needed; the first reads and processes .pth files and the second makes sure that Homebrew's site-packages is read before the system extras, so that formulas depending on Homebrew/python/numpy get the Homebrew/python version and not the old system version. Closes #38466.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 88c5c5449..9154ecc89 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -634,6 +634,7 @@ class Formula
mktemp do
@testpath = Pathname.pwd
ENV["HOME"] = @testpath
+ setup_test_home @testpath
test
end
ensure
@@ -658,6 +659,16 @@ class Formula
protected
+ def setup_test_home home
+ # keep Homebrew's site-packages in sys.path when testing with system Python
+ user_site_packages = home/"Library/Python/2.7/lib/python/site-packages"
+ user_site_packages.mkpath
+ (user_site_packages/"homebrew.pth").write <<-EOS.undent
+ import site; site.addsitedir("#{HOMEBREW_PREFIX}/lib/python2.7/site-packages")
+ import sys; sys.path.insert(0, "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages")
+ EOS
+ end
+
# Pretty titles the command and buffers stdout/stderr
# Throws if there's an error
def system cmd, *args