2
2
import importlib
3
3
import zipfile
4
4
import glob
5
- from six import PY2
5
+ from six import PY2 , with_metaclass
6
6
7
7
import sh
8
8
import shutil
@@ -37,8 +37,19 @@ def import_recipe(module, filename):
37
37
return SourceFileLoader (module , filename ).load_module ()
38
38
39
39
40
- class Recipe (object ):
41
- url = None
40
+ class RecipeMeta (type ):
41
+ def __new__ (cls , name , bases , dct ):
42
+ if name != 'Recipe' :
43
+ if 'url' in dct :
44
+ dct ['_url' ] = dct .pop ('url' )
45
+ if 'version' in dct :
46
+ dct ['_version' ] = dct .pop ('version' )
47
+
48
+ return super (RecipeMeta , cls ).__new__ (cls , name , bases , dct )
49
+
50
+
51
+ class Recipe (with_metaclass (RecipeMeta )):
52
+ _url = None
42
53
'''The address from which the recipe may be downloaded. This is not
43
54
essential, it may be omitted if the source is available some other
44
55
way, such as via the :class:`IncludedFilesBehaviour` mixin.
@@ -52,7 +63,7 @@ class Recipe(object):
52
63
if you want.
53
64
'''
54
65
55
- version = None
66
+ _version = None
56
67
'''A string giving the version of the software the recipe describes,
57
68
e.g. ``2.0.3`` or ``master``.'''
58
69
@@ -88,6 +99,16 @@ class Recipe(object):
88
99
89
100
archs = ['armeabi' ] # Not currently implemented properly
90
101
102
+ @property
103
+ def version (self ):
104
+ key = 'VERSION_' + self .name
105
+ return environ .get (key , self ._version )
106
+
107
+ @property
108
+ def url (self ):
109
+ key = 'URL_' + self .name
110
+ return environ .get (key , self ._url )
111
+
91
112
@property
92
113
def versioned_url (self ):
93
114
'''A property returning the url of the recipe with ``{version}``
0 commit comments