Remove more nesting in python_helper
This commit is contained in:
parent
eafa7a141d
commit
53c97c3c96
@ -55,36 +55,34 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
|
||||
filtered_python_reqs.sort_by{ |py| py.version }.map do |py|
|
||||
# Now is the time to set the site_packages to the correct value
|
||||
py.site_packages = lib/py.xy/'site-packages'
|
||||
if !block_given?
|
||||
return py
|
||||
else
|
||||
puts "brew: Python block (#{py.binary})..." if ARGV.verbose? && ARGV.debug?
|
||||
# Ensure env changes are only temporary
|
||||
begin
|
||||
old_env = ENV.to_hash
|
||||
# In order to install into the Cellar, the dir must exist and be in the
|
||||
# PYTHONPATH. This will be executed in the context of the formula
|
||||
# so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
|
||||
puts "brew: Appending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
|
||||
mkdir_p py.site_packages
|
||||
ENV.append 'PYTHONPATH', py.site_packages, ':'
|
||||
ENV['PYTHON'] = py.binary
|
||||
ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
|
||||
ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
|
||||
ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
|
||||
#Note: Don't set LDFLAGS to point to the Python.framework, because
|
||||
# it breaks builds (for example scipy.)
|
||||
return py if !block_given?
|
||||
|
||||
# Track the state of the currently selected python for this block,
|
||||
# so if this python_helper is called again _inside_ the block,
|
||||
# we can just return the right python (see `else`-branch a few lines down):
|
||||
@current_python = py
|
||||
res = instance_eval(&block)
|
||||
@current_python = nil
|
||||
res
|
||||
ensure
|
||||
ENV.replace(old_env)
|
||||
end
|
||||
puts "brew: Python block (#{py.binary})..." if ARGV.verbose? && ARGV.debug?
|
||||
# Ensure env changes are only temporary
|
||||
begin
|
||||
old_env = ENV.to_hash
|
||||
# In order to install into the Cellar, the dir must exist and be in the
|
||||
# PYTHONPATH. This will be executed in the context of the formula
|
||||
# so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
|
||||
puts "brew: Appending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
|
||||
mkdir_p py.site_packages
|
||||
ENV.append 'PYTHONPATH', py.site_packages, ':'
|
||||
ENV['PYTHON'] = py.binary
|
||||
ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
|
||||
ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
|
||||
ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
|
||||
#Note: Don't set LDFLAGS to point to the Python.framework, because
|
||||
# it breaks builds (for example scipy.)
|
||||
|
||||
# Track the state of the currently selected python for this block,
|
||||
# so if this python_helper is called again _inside_ the block,
|
||||
# we can just return the right python (see `else`-branch a few lines down):
|
||||
@current_python = py
|
||||
res = instance_eval(&block)
|
||||
@current_python = nil
|
||||
res
|
||||
ensure
|
||||
ENV.replace(old_env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user