@@ -1091,6 +1091,80 @@ def reduce_object_file_names(self, dirn):
1091
1091
shprint (sh .mv , filen , join (file_dirname , parts [0 ] + '.so' ))
1092
1092
1093
1093
1094
+ class TargetHostPythonRecipe (Recipe ):
1095
+ '''
1096
+ This is the base class for the hostpython recipes. This class will take
1097
+ care to do all the work to build a hostpython recipe but, be careful, it
1098
+ is intended to be subclassed because some of the vars needs to be set:
1099
+
1100
+ - :attr:`name`
1101
+ - :attr:`version`
1102
+
1103
+ .. versionadded:: 0.6.0
1104
+ '''
1105
+
1106
+ name = ''
1107
+ '''The hostpython's recipe name. This should be ``hostpython2`` or
1108
+ ``hostpython3``
1109
+
1110
+ .. warning:: This must be set in inherited class.'''
1111
+
1112
+ version = ''
1113
+ '''The hostpython's recipe version.
1114
+
1115
+ .. warning:: This must be set in inherited class.'''
1116
+
1117
+ build_subdir = 'native-build'
1118
+ '''Specify the sub build directory for the hostpython recipe. Defaults
1119
+ to ``native-build``.'''
1120
+
1121
+ url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
1122
+ '''The default url to download our host python recipe. This url will
1123
+ change depending on the python version set in attribute :attr:`version`.'''
1124
+
1125
+ def get_build_container_dir (self , arch = None ):
1126
+ choices = self .check_recipe_choices ()
1127
+ dir_name = '-' .join ([self .name ] + choices )
1128
+ return join (self .ctx .build_dir , 'other_builds' , dir_name , 'desktop' )
1129
+
1130
+ def get_build_dir (self , arch = None ):
1131
+ '''
1132
+ .. note:: Unlike other recipes, the hostpython build dir doesn't
1133
+ depend on the target arch
1134
+ '''
1135
+ return join (self .get_build_container_dir (), self .name )
1136
+
1137
+ def get_path_to_python (self ):
1138
+ return join (self .get_build_dir (), self .build_subdir )
1139
+
1140
+ def build_arch (self , arch ):
1141
+ recipe_build_dir = self .get_build_dir (arch .arch )
1142
+
1143
+ # Create a subdirectory to actually perform the build
1144
+ build_dir = join (recipe_build_dir , self .build_subdir )
1145
+ ensure_dir (build_dir )
1146
+
1147
+ if not exists (join (build_dir , 'python' )):
1148
+ with current_directory (recipe_build_dir ):
1149
+ # Configure the build
1150
+ with current_directory (build_dir ):
1151
+ if not exists ('config.status' ):
1152
+ shprint (
1153
+ sh .Command (join (recipe_build_dir , 'configure' )))
1154
+
1155
+ # Create the Setup file. This copying from Setup.dist
1156
+ # seems to be the normal and expected procedure.
1157
+ shprint (sh .cp , join ('Modules' , 'Setup.dist' ),
1158
+ join (build_dir , 'Modules' , 'Setup' ))
1159
+
1160
+ result = shprint (sh .make , '-C' , build_dir )
1161
+ else :
1162
+ info ('Skipping {name} ({version}) build, as it has already '
1163
+ 'been completed' .format (name = self .name , version = self .version ))
1164
+
1165
+ self .ctx .hostpython = join (build_dir , 'python' )
1166
+
1167
+
1094
1168
def md5sum (filen ):
1095
1169
'''Calculate the md5sum of a file.
1096
1170
'''
0 commit comments