5
5
6
6
from . import BOB_VERSION , BOB_INPUT_HASH , DEBUG
7
7
from .errors import ParseError , BobError
8
- from .languages import getLanguage , ScriptLanguage , BashLanguage , PwshLanguage
8
+ from .languages import getLanguage , ScriptLanguage , BashLanguage , PwshLanguage , PythonLanguage
9
9
from .pathspec import PackageSet
10
10
from .scm import CvsScm , GitScm , ImportScm , SvnScm , UrlScm , ScmOverride , \
11
11
auditFromDir , getScm , SYNTHETIC_SCM_PROPS
@@ -115,9 +115,11 @@ def fetchFingerprintScripts(recipe):
115
115
recipe .get ("fingerprintScript" )),
116
116
ScriptLanguage .PWSH : recipe .get ("fingerprintScriptPwsh" ,
117
117
recipe .get ("fingerprintScript" )),
118
+ ScriptLanguage .PYTHON : recipe .get ("fingerprintScriptPython" ,
119
+ recipe .get ("fingerprintScript" )),
118
120
}
119
121
120
- def fetchScripts (recipe , prefix , resolveBash , resolvePwsh ):
122
+ def fetchScripts (recipe , prefix , resolveBash , resolvePwsh , resolvePython ):
121
123
return {
122
124
ScriptLanguage .BASH : (
123
125
resolveBash (recipe .get (prefix + "SetupBash" , recipe .get (prefix + "Setup" )),
@@ -130,7 +132,13 @@ def fetchScripts(recipe, prefix, resolveBash, resolvePwsh):
130
132
prefix + "Setup[Pwsh]" ),
131
133
resolvePwsh (recipe .get (prefix + "ScriptPwsh" , recipe .get (prefix + "Script" )),
132
134
prefix + "Script[Pwsh]" ),
133
- )
135
+ ),
136
+ ScriptLanguage .PYTHON : (
137
+ resolvePython (recipe .get (prefix + "SetupPython" , recipe .get (prefix + "Setup" )),
138
+ prefix + "Setup[Python]" ),
139
+ resolvePython (recipe .get (prefix + "ScriptPython" , recipe .get (prefix + "Script" )),
140
+ prefix + "Script[Python]" ),
141
+ ),
134
142
}
135
143
136
144
def mergeScripts (fragments , glue ):
@@ -2187,9 +2195,11 @@ def __init__(self, recipeSet, recipe, layer, sourceFile, baseDir, packageName, b
2187
2195
baseDir , packageName , sourceName ).resolve
2188
2196
incHelperPwsh = IncludeHelper (PwshLanguage , recipeSet .loadBinary ,
2189
2197
baseDir , packageName , sourceName ).resolve
2198
+ incHelperPython = IncludeHelper (PythonLanguage , recipeSet .loadBinary ,
2199
+ baseDir , packageName , sourceName ).resolve
2190
2200
2191
2201
self .__scriptLanguage = recipe .get ("scriptLanguage" )
2192
- self .__checkout = fetchScripts (recipe , "checkout" , incHelperBash , incHelperPwsh )
2202
+ self .__checkout = fetchScripts (recipe , "checkout" , incHelperBash , incHelperPwsh , incHelperPython )
2193
2203
self .__checkoutSCMs = recipe .get ("checkoutSCM" , [])
2194
2204
for scm in self .__checkoutSCMs :
2195
2205
scm ["__source" ] = sourceName
@@ -2199,8 +2209,8 @@ def __init__(self, recipeSet, recipe, layer, sourceFile, baseDir, packageName, b
2199
2209
for a in self .__checkoutAsserts :
2200
2210
a ["__source" ] = sourceName + ", checkoutAssert #{}" .format (i )
2201
2211
i += 1
2202
- self .__build = fetchScripts (recipe , "build" , incHelperBash , incHelperPwsh )
2203
- self .__package = fetchScripts (recipe , "package" , incHelperBash , incHelperPwsh )
2212
+ self .__build = fetchScripts (recipe , "build" , incHelperBash , incHelperPwsh , incHelperPython )
2213
+ self .__package = fetchScripts (recipe , "package" , incHelperBash , incHelperPwsh , incHelperPython )
2204
2214
self .__fingerprintScriptList = fetchFingerprintScripts (recipe )
2205
2215
self .__fingerprintIf = recipe .get ("fingerprintIf" )
2206
2216
self .__fingerprintVarsList = set (recipe .get ("fingerprintVars" , []))
@@ -3055,7 +3065,7 @@ class RecipeSet:
3055
3065
),
3056
3066
schema .Optional ('layers' ) : [str ],
3057
3067
schema .Optional ('scriptLanguage' ,
3058
- default = ScriptLanguage .BASH ) : schema .And (schema .Or ("bash" , "PowerShell" ),
3068
+ default = ScriptLanguage .BASH ) : schema .And (schema .Or ("bash" , "PowerShell" , "python" ),
3059
3069
schema .Use (ScriptLanguage )),
3060
3070
})
3061
3071
@@ -3653,21 +3663,27 @@ def __createSchemas(self):
3653
3663
schema .Optional ('checkoutScript' ) : str ,
3654
3664
schema .Optional ('checkoutScriptBash' ) : str ,
3655
3665
schema .Optional ('checkoutScriptPwsh' ) : str ,
3666
+ schema .Optional ('checkoutScriptPython' ) : str ,
3656
3667
schema .Optional ('checkoutSetup' ) : str ,
3657
3668
schema .Optional ('checkoutSetupBash' ) : str ,
3658
3669
schema .Optional ('checkoutSetupPwsh' ) : str ,
3670
+ schema .Optional ('checkoutSetupPython' ) : str ,
3659
3671
schema .Optional ('buildScript' ) : str ,
3660
3672
schema .Optional ('buildScriptBash' ) : str ,
3661
3673
schema .Optional ('buildScriptPwsh' ) : str ,
3674
+ schema .Optional ('buildScriptPython' ) : str ,
3662
3675
schema .Optional ('buildSetup' ) : str ,
3663
3676
schema .Optional ('buildSetupBash' ) : str ,
3664
3677
schema .Optional ('buildSetupPwsh' ) : str ,
3678
+ schema .Optional ('buildSetupPython' ) : str ,
3665
3679
schema .Optional ('packageScript' ) : str ,
3666
3680
schema .Optional ('packageScriptBash' ) : str ,
3667
3681
schema .Optional ('packageScriptPwsh' ) : str ,
3682
+ schema .Optional ('packageScriptPython' ) : str ,
3668
3683
schema .Optional ('packageSetup' ) : str ,
3669
3684
schema .Optional ('packageSetupBash' ) : str ,
3670
3685
schema .Optional ('packageSetupPwsh' ) : str ,
3686
+ schema .Optional ('packageSetupPython' ) : str ,
3671
3687
schema .Optional ('checkoutTools' ) : [ toolNameSchema ],
3672
3688
schema .Optional ('buildTools' ) : [ toolNameSchema ],
3673
3689
schema .Optional ('packageTools' ) : [ toolNameSchema ],
@@ -3705,6 +3721,7 @@ def __createSchemas(self):
3705
3721
schema .Optional ('fingerprintScript' , default = "" ) : str ,
3706
3722
schema .Optional ('fingerprintScriptBash' ) : str ,
3707
3723
schema .Optional ('fingerprintScriptPwsh' , default = "" ) : str ,
3724
+ schema .Optional ('fingerprintScriptPython' , default = "" ) : str ,
3708
3725
schema .Optional ('fingerprintIf' ) : schema .Or (None , str , bool , IfExpression ),
3709
3726
schema .Optional ('fingerprintVars' ) : [ varNameUseSchema ],
3710
3727
})
@@ -3725,9 +3742,10 @@ def __createSchemas(self):
3725
3742
schema .Optional ('fingerprintScript' , default = "" ) : str ,
3726
3743
schema .Optional ('fingerprintScriptBash' ) : str ,
3727
3744
schema .Optional ('fingerprintScriptPwsh' , default = "" ) : str ,
3745
+ schema .Optional ('fingerprintScriptPython' , default = "" ) : str ,
3728
3746
schema .Optional ('fingerprintIf' ) : schema .Or (None , str , bool , IfExpression ),
3729
3747
schema .Optional ('fingerprintVars' ) : [ varNameUseSchema ],
3730
- schema .Optional ('scriptLanguage' ) : schema .And (schema .Or ("bash" , "PowerShell" ),
3748
+ schema .Optional ('scriptLanguage' ) : schema .And (schema .Or ("bash" , "PowerShell" , "python" ),
3731
3749
schema .Use (ScriptLanguage )),
3732
3750
schema .Optional ('jobServer' ) : bool ,
3733
3751
}
0 commit comments