aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements/python_dependency.rb
diff options
context:
space:
mode:
authorSamuel John2013-07-16 11:04:57 +0200
committerSamuel John2013-07-16 11:04:57 +0200
commitfb7f16fc94d1b7d828322bcf8dcbae041da56ff5 (patch)
tree375808a85d4fbbafbb17ba4ece6b0b706ac92ddf /Library/Homebrew/requirements/python_dependency.rb
parent9fb163d34cdf3b303f6d22436d6b177a778b4015 (diff)
downloadbrew-fb7f16fc94d1b7d828322bcf8dcbae041da56ff5.tar.bz2
Allow specifying version in depends_on :python
Note, in the explict form: PythonInstalled.new('2.7') => :recommended the tag :recommended is ignored (not a limitation of PythonInstalled itself). One solution was to write PythonInstalled.new('2.7', [:recommended]) but that is not as beautiful as we like it. Therefore, now it is possible to: depends_on :python => ['2.7', :recommended] Only the first tag is attempted to be parsed as a version specifyer "x" or "x.y" or "x.y.z"...
Diffstat (limited to 'Library/Homebrew/requirements/python_dependency.rb')
-rw-r--r--Library/Homebrew/requirements/python_dependency.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb
index 0c182b66b..3130d1c77 100644
--- a/Library/Homebrew/requirements/python_dependency.rb
+++ b/Library/Homebrew/requirements/python_dependency.rb
@@ -31,15 +31,16 @@ class PythonInstalled < Requirement
end
end
- def initialize(version="2.6", *tags )
- # Extract the min_version if given. Default to python 2.X else
- if /(\d+\.)*\d+/ === version.to_s
- @min_version = PythonVersion.new(version)
+ def initialize(default_version="2.6", tags=[] )
+ tags = [tags].flatten
+ # Extract the min_version if given. Default to default_version else
+ if /(\d+\.)*\d+/ === tags.first.to_s
+ @min_version = PythonVersion.new(tags.shift)
else
- raise "Invalid version specification for Python: '#{version}'"
+ @min_version = PythonVersion.new(default_version)
end
- # often used idiom: e.g. sipdir = "share/sip" + python.if3then3
+ # often used idiom: e.g. sipdir = "share/sip#{python.if3then3}"
if @min_version.major == 3
@if3then3 = "3"
else
@@ -56,7 +57,7 @@ class PythonInstalled < Requirement
@imports = {}
tags.each do |tag|
if tag.kind_of? String
- @imports[tag] = tag
+ @imports[tag] = tag # if the module name is the same as the PyPi name
elsif tag.kind_of? Hash
@imports.merge!(tag)
end