55
66from . import BOB_VERSION , BOB_INPUT_HASH , DEBUG
77from .errors import ParseError , BobError
8- from .languages import getLanguage , ScriptLanguage , BashLanguage , PwshLanguage
8+ from .languages import getLanguage , ScriptLanguage , BashLanguage , PwshLanguage , PythonLanguage
99from .pathspec import PackageSet
1010from .scm import CvsScm , GitScm , ImportScm , SvnScm , UrlScm , ScmOverride , \
1111 auditFromDir , getScm , SYNTHETIC_SCM_PROPS
@@ -115,9 +115,11 @@ def fetchFingerprintScripts(recipe):
115115 recipe .get ("fingerprintScript" )),
116116 ScriptLanguage .PWSH : recipe .get ("fingerprintScriptPwsh" ,
117117 recipe .get ("fingerprintScript" )),
118+ ScriptLanguage .PYTHON : recipe .get ("fingerprintScriptPython" ,
119+ recipe .get ("fingerprintScript" )),
118120 }
119121
120- def fetchScripts (recipe , prefix , resolveBash , resolvePwsh ):
122+ def fetchScripts (recipe , prefix , resolveBash , resolvePwsh , resolvePython ):
121123 return {
122124 ScriptLanguage .BASH : (
123125 resolveBash (recipe .get (prefix + "SetupBash" , recipe .get (prefix + "Setup" )),
@@ -130,7 +132,13 @@ def fetchScripts(recipe, prefix, resolveBash, resolvePwsh):
130132 prefix + "Setup[Pwsh]" ),
131133 resolvePwsh (recipe .get (prefix + "ScriptPwsh" , recipe .get (prefix + "Script" )),
132134 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+ ),
134142 }
135143
136144def mergeScripts (fragments , glue ):
@@ -2187,9 +2195,11 @@ def __init__(self, recipeSet, recipe, layer, sourceFile, baseDir, packageName, b
21872195 baseDir , packageName , sourceName ).resolve
21882196 incHelperPwsh = IncludeHelper (PwshLanguage , recipeSet .loadBinary ,
21892197 baseDir , packageName , sourceName ).resolve
2198+ incHelperPython = IncludeHelper (PythonLanguage , recipeSet .loadBinary ,
2199+ baseDir , packageName , sourceName ).resolve
21902200
21912201 self .__scriptLanguage = recipe .get ("scriptLanguage" )
2192- self .__checkout = fetchScripts (recipe , "checkout" , incHelperBash , incHelperPwsh )
2202+ self .__checkout = fetchScripts (recipe , "checkout" , incHelperBash , incHelperPwsh , incHelperPython )
21932203 self .__checkoutSCMs = recipe .get ("checkoutSCM" , [])
21942204 for scm in self .__checkoutSCMs :
21952205 scm ["__source" ] = sourceName
@@ -2199,8 +2209,8 @@ def __init__(self, recipeSet, recipe, layer, sourceFile, baseDir, packageName, b
21992209 for a in self .__checkoutAsserts :
22002210 a ["__source" ] = sourceName + ", checkoutAssert #{}" .format (i )
22012211 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 )
22042214 self .__fingerprintScriptList = fetchFingerprintScripts (recipe )
22052215 self .__fingerprintIf = recipe .get ("fingerprintIf" )
22062216 self .__fingerprintVarsList = set (recipe .get ("fingerprintVars" , []))
@@ -3055,7 +3065,7 @@ class RecipeSet:
30553065 ),
30563066 schema .Optional ('layers' ) : [str ],
30573067 schema .Optional ('scriptLanguage' ,
3058- default = ScriptLanguage .BASH ) : schema .And (schema .Or ("bash" , "PowerShell" ),
3068+ default = ScriptLanguage .BASH ) : schema .And (schema .Or ("bash" , "PowerShell" , "python" ),
30593069 schema .Use (ScriptLanguage )),
30603070 })
30613071
@@ -3653,21 +3663,27 @@ def __createSchemas(self):
36533663 schema .Optional ('checkoutScript' ) : str ,
36543664 schema .Optional ('checkoutScriptBash' ) : str ,
36553665 schema .Optional ('checkoutScriptPwsh' ) : str ,
3666+ schema .Optional ('checkoutScriptPython' ) : str ,
36563667 schema .Optional ('checkoutSetup' ) : str ,
36573668 schema .Optional ('checkoutSetupBash' ) : str ,
36583669 schema .Optional ('checkoutSetupPwsh' ) : str ,
3670+ schema .Optional ('checkoutSetupPython' ) : str ,
36593671 schema .Optional ('buildScript' ) : str ,
36603672 schema .Optional ('buildScriptBash' ) : str ,
36613673 schema .Optional ('buildScriptPwsh' ) : str ,
3674+ schema .Optional ('buildScriptPython' ) : str ,
36623675 schema .Optional ('buildSetup' ) : str ,
36633676 schema .Optional ('buildSetupBash' ) : str ,
36643677 schema .Optional ('buildSetupPwsh' ) : str ,
3678+ schema .Optional ('buildSetupPython' ) : str ,
36653679 schema .Optional ('packageScript' ) : str ,
36663680 schema .Optional ('packageScriptBash' ) : str ,
36673681 schema .Optional ('packageScriptPwsh' ) : str ,
3682+ schema .Optional ('packageScriptPython' ) : str ,
36683683 schema .Optional ('packageSetup' ) : str ,
36693684 schema .Optional ('packageSetupBash' ) : str ,
36703685 schema .Optional ('packageSetupPwsh' ) : str ,
3686+ schema .Optional ('packageSetupPython' ) : str ,
36713687 schema .Optional ('checkoutTools' ) : [ toolNameSchema ],
36723688 schema .Optional ('buildTools' ) : [ toolNameSchema ],
36733689 schema .Optional ('packageTools' ) : [ toolNameSchema ],
@@ -3705,6 +3721,7 @@ def __createSchemas(self):
37053721 schema .Optional ('fingerprintScript' , default = "" ) : str ,
37063722 schema .Optional ('fingerprintScriptBash' ) : str ,
37073723 schema .Optional ('fingerprintScriptPwsh' , default = "" ) : str ,
3724+ schema .Optional ('fingerprintScriptPython' , default = "" ) : str ,
37083725 schema .Optional ('fingerprintIf' ) : schema .Or (None , str , bool , IfExpression ),
37093726 schema .Optional ('fingerprintVars' ) : [ varNameUseSchema ],
37103727 })
@@ -3725,9 +3742,10 @@ def __createSchemas(self):
37253742 schema .Optional ('fingerprintScript' , default = "" ) : str ,
37263743 schema .Optional ('fingerprintScriptBash' ) : str ,
37273744 schema .Optional ('fingerprintScriptPwsh' , default = "" ) : str ,
3745+ schema .Optional ('fingerprintScriptPython' , default = "" ) : str ,
37283746 schema .Optional ('fingerprintIf' ) : schema .Or (None , str , bool , IfExpression ),
37293747 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" ),
37313749 schema .Use (ScriptLanguage )),
37323750 schema .Optional ('jobServer' ) : bool ,
37333751 }
0 commit comments