Merge pull request #299 from epfl-scitas/enhancement/os_detection
enhancement proposal : boolean support for when=<arg>
This commit is contained in:
commit
7176e5ef07
@ -174,7 +174,11 @@ def version(pkg, ver, checksum=None, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def _depends_on(pkg, spec, when=None):
|
def _depends_on(pkg, spec, when=None):
|
||||||
if when is None:
|
# If when is False do nothing
|
||||||
|
if when is False:
|
||||||
|
return
|
||||||
|
# If when is None or True make sure the condition is always satisfied
|
||||||
|
if when is None or when is True:
|
||||||
when = pkg.name
|
when = pkg.name
|
||||||
when_spec = parse_anonymous_spec(when, pkg.name)
|
when_spec = parse_anonymous_spec(when, pkg.name)
|
||||||
|
|
||||||
|
@ -193,10 +193,11 @@ def install(self, prefix):
|
|||||||
platform-specific versions. There's not much we can do to get
|
platform-specific versions. There's not much we can do to get
|
||||||
around this because of the way decorators work.
|
around this because of the way decorators work.
|
||||||
"""
|
"""
|
||||||
class when(object):
|
|
||||||
def __init__(self, spec):
|
def __init__(self, spec):
|
||||||
pkg = get_calling_module_name()
|
pkg = get_calling_module_name()
|
||||||
self.spec = parse_anonymous_spec(spec, pkg)
|
if spec is True:
|
||||||
|
spec = pkg
|
||||||
|
self.spec = parse_anonymous_spec(spec, pkg) if spec is not False else None
|
||||||
|
|
||||||
def __call__(self, method):
|
def __call__(self, method):
|
||||||
# Get the first definition of the method in the calling scope
|
# Get the first definition of the method in the calling scope
|
||||||
@ -207,7 +208,9 @@ def __call__(self, method):
|
|||||||
if not type(original_method) == SpecMultiMethod:
|
if not type(original_method) == SpecMultiMethod:
|
||||||
original_method = SpecMultiMethod(original_method)
|
original_method = SpecMultiMethod(original_method)
|
||||||
|
|
||||||
original_method.register(self.spec, method)
|
if self.spec is not None:
|
||||||
|
original_method.register(self.spec, method)
|
||||||
|
|
||||||
return original_method
|
return original_method
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user