Skip to content
Snippets Groups Projects
Commit a5e1f698 authored by Tim D. Smith's avatar Tim D. Smith
Browse files

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 Homebrew/homebrew#38466.
parent f5c8e3fd
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment