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"...
This commit is contained in:
parent
9fb163d34c
commit
fb7f16fc94
@ -70,7 +70,7 @@ class DependencyCollector
|
|||||||
elsif (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
elsif (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
|
||||||
# Next line only for legacy support of `depends_on 'module' => :python`
|
# Next line only for legacy support of `depends_on 'module' => :python`
|
||||||
# It should be replaced by `depends_on :python => 'module'`
|
# It should be replaced by `depends_on :python => 'module'`
|
||||||
return PythonInstalled.new("2", spec, *tags) if tag == :python
|
return PythonInstalled.new("2", spec) if tag == :python
|
||||||
LanguageModuleDependency.new(tag, spec)
|
LanguageModuleDependency.new(tag, spec)
|
||||||
else
|
else
|
||||||
Dependency.new(spec, tags)
|
Dependency.new(spec, tags)
|
||||||
@ -99,8 +99,8 @@ class DependencyCollector
|
|||||||
when :clt then CLTDependency.new(tags)
|
when :clt then CLTDependency.new(tags)
|
||||||
when :arch then ArchRequirement.new(tags)
|
when :arch then ArchRequirement.new(tags)
|
||||||
when :hg then MercurialDependency.new(tags)
|
when :hg then MercurialDependency.new(tags)
|
||||||
when :python, :python2 then PythonInstalled.new("2", *tags)
|
when :python, :python2 then PythonInstalled.new("2", tags)
|
||||||
when :python3 then PythonInstalled.new("3", *tags)
|
when :python3 then PythonInstalled.new("3", tags)
|
||||||
# Tiger's ld is too old to properly link some software
|
# Tiger's ld is too old to properly link some software
|
||||||
when :ld64 then LD64Dependency.new if MacOS.version < :leopard
|
when :ld64 then LD64Dependency.new if MacOS.version < :leopard
|
||||||
else
|
else
|
||||||
|
|||||||
@ -31,15 +31,16 @@ class PythonInstalled < Requirement
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(version="2.6", *tags )
|
def initialize(default_version="2.6", tags=[] )
|
||||||
# Extract the min_version if given. Default to python 2.X else
|
tags = [tags].flatten
|
||||||
if /(\d+\.)*\d+/ === version.to_s
|
# Extract the min_version if given. Default to default_version else
|
||||||
@min_version = PythonVersion.new(version)
|
if /(\d+\.)*\d+/ === tags.first.to_s
|
||||||
|
@min_version = PythonVersion.new(tags.shift)
|
||||||
else
|
else
|
||||||
raise "Invalid version specification for Python: '#{version}'"
|
@min_version = PythonVersion.new(default_version)
|
||||||
end
|
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
|
if @min_version.major == 3
|
||||||
@if3then3 = "3"
|
@if3then3 = "3"
|
||||||
else
|
else
|
||||||
@ -56,7 +57,7 @@ class PythonInstalled < Requirement
|
|||||||
@imports = {}
|
@imports = {}
|
||||||
tags.each do |tag|
|
tags.each do |tag|
|
||||||
if tag.kind_of? String
|
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
|
elsif tag.kind_of? Hash
|
||||||
@imports.merge!(tag)
|
@imports.merge!(tag)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user