Python add -F#{python.framework} for brewed Python

Since Python has been removed from superenv and
added as an explicit `depends_on :python`,
we should add
`-F#{HOMEBREW_PREFIX}/opt/python/Framewoks`
so that build tools that don't use
`python-config --ldflags` (as they should!)
can link against brewed Python.
This commit is contained in:
Samuel John 2013-06-05 14:42:26 +02:00
parent 4dac954cdb
commit 7aa2bcc3d5
3 changed files with 11 additions and 4 deletions

View File

@ -64,6 +64,7 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':' ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx? ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
ENV.prepend 'LDFLAGS', "-F#{py.framework}" if py.brewed?
# Track the state of the currently selected python for this block, # Track the state of the currently selected python for this block,
# so if this python_helper is called again _inside_ the block, we can # 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): # just return the right python (see `else`-branch a few lines down):

View File

@ -177,10 +177,14 @@ class PythonInstalled < Requirement
@pypy ||= !(`#{binary} -c "import sys; print(sys.version)"`.downcase =~ /.*pypy.*/).nil? @pypy ||= !(`#{binary} -c "import sys; print(sys.version)"`.downcase =~ /.*pypy.*/).nil?
end end
# Is this python a framework-style install (OS X only)? def framework
def framework? # We return the path to Frameworks and not the 'Python.framework', because
@framework ||= /Python[0-9]*\.framework/ === prefix.to_s # the latter is (sadly) the same for 2.x and 3.x.
if prefix.to_s =~ /^(.*\/Frameworks)\/(Python\.framework).*$/
@framework = $1
end end
end
def framework?; not framework.nil? end
def universal? def universal?
@universal ||= archs_for_command(binary).universal? @universal ||= archs_for_command(binary).universal?
@ -215,6 +219,9 @@ class PythonInstalled < Requirement
# ENV['ARCHFLAGS'] = ??? # FIXME # ENV['ARCHFLAGS'] = ??? # FIXME
ENV.append 'CMAKE_INCLUDE_PATH', incdir, ':' ENV.append 'CMAKE_INCLUDE_PATH', incdir, ':'
ENV.append 'PKG_CONFIG_PATH', pkg_config_path, ':' if pkg_config_path ENV.append 'PKG_CONFIG_PATH', pkg_config_path, ':' if pkg_config_path
# We don't set the -F#{framework} here, because if Python 2.x and 3.x are
# used, `Python.framework` is ambuig. However, in the `python do` block
# we can set LDFLAGS+="-F#{framework}" because only one is temporarily set.
# Udpate distutils.cfg (later we can remove this, but people still have # Udpate distutils.cfg (later we can remove this, but people still have
# their old brewed pythons and we have to update it here) # their old brewed pythons and we have to update it here)

View File

@ -161,7 +161,6 @@ class << ENV
def determine_cmake_frameworks_path def determine_cmake_frameworks_path
# XXX: keg_only_deps perhaps? but Qt does not link its Frameworks because of Ruby's Find.find ignoring symlinks!! # XXX: keg_only_deps perhaps? but Qt does not link its Frameworks because of Ruby's Find.find ignoring symlinks!!
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" } paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" }
paths << "#{HOMEBREW_PREFIX}/Frameworks"
paths << "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt? paths << "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt?
paths.to_path_s paths.to_path_s
end end