aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2014-03-07 18:05:56 +0000
committerMike McQuaid2014-03-12 13:56:41 +0000
commit078e26e16550dbeaed1be4b68ee8b9225aa1da63 (patch)
treeabe2001bc29076cf1f68be67eb9541de98feada0
parent23818b3718f10eaa8e61768fa03cf122568dcc79 (diff)
downloadhomebrew-078e26e16550dbeaed1be4b68ee8b9225aa1da63.tar.bz2
python_dependency: fixes, features, cleanup.
- PythonDependency now implies Python 2.7 - PythonDependency now uses brewed Python for bottling - Use double-quotes everywhere Closes #27112.
-rw-r--r--Library/Homebrew/requirements/python_dependency.rb48
1 files changed, 28 insertions, 20 deletions
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb
index 586821f6c..246fbec2e 100644
--- a/Library/Homebrew/requirements/python_dependency.rb
+++ b/Library/Homebrew/requirements/python_dependency.rb
@@ -1,46 +1,54 @@
-require 'requirement'
+require "language/python"
class PythonDependency < Requirement
fatal true
+ default_formula "python"
satisfy :build_env => false do
- which_python
- end
-
- def which_python
- @which_python ||= which python_binary
+ python = which_python
+ next unless python
+ version = python_short_version
+ next unless version
+ # Always use Python 2.7 for consistency on older versions of OSX.
+ version == Version.new("2.7")
end
def modify_build_environment
if system_python?
- if python_binary == 'python'
- ENV['PYTHONPATH'] = "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"
+ if python_binary == "python"
+ version = python_short_version
+ ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages"
end
elsif which_python
- ENV.prepend_path 'PATH', which_python.dirname
+ ENV.prepend_path "PATH", which_python.dirname
end
end
- def system_python?
- which_python.to_s == "/usr/bin/#{python_binary}"
+ def python_short_version
+ @short_version ||= Language::Python.major_minor_version which_python
end
- def python_binary
- 'python'
+ def which_python
+ python = which python_binary
+ return unless python
+ executable = `#{python} -c "import sys; print(sys.executable)"`.strip
+ return unless executable
+ Pathname.new executable
end
+ def system_python; "/usr/bin/#{python_binary}" end
+ def system_python?; system_python == which_python.to_s end
+ def python_binary; "python" end
+
# Deprecated
alias_method :to_s, :python_binary
end
class Python3Dependency < PythonDependency
- default_formula 'python3'
+ fatal true
+ default_formula "python3"
- satisfy :build_env => false do
- which_python
- end
+ satisfy(:build_env => false) { which_python }
- def python_binary
- 'python3'
- end
+ def python_binary; "python3" end
end