@@ -130,6 +130,13 @@ def _get_tensorflow_library(self, host):
130
130
131
131
raise RuntimeError ('unknown host target {}' .format (host ))
132
132
133
+ def _symlink (self , dest , src ):
134
+ try :
135
+ os .unlink (src )
136
+ except OSError :
137
+ pass
138
+ os .symlink (dest , src )
139
+
133
140
def build (self , host_target ):
134
141
with shell .pushd (self .source_dir ):
135
142
# Run the TensorFlow configure script: `yes "" | ./configure`.
@@ -202,16 +209,24 @@ def install(self, host_target):
202
209
'usr' , 'lib' , 'swift' ,
203
210
subdir , suffixed_lib_name ))
204
211
205
- try :
206
- os .unlink (os .path .join (self .install_toolchain_path (),
207
- 'usr' , 'lib' , 'swift' ,
208
- subdir , unsuffixed_lib_name ))
209
- except OSError :
210
- pass
211
- os .symlink (suffixed_lib_name ,
212
- os .path .join (self .install_toolchain_path (),
213
- 'usr' , 'lib' , 'swift' ,
214
- subdir , unsuffixed_lib_name ))
212
+ if host_target .startswith ('linux' ):
213
+ versions = (
214
+ 'libtensorflow.so.2.1.0' ,
215
+ 'libtensorflow.so.2.1' ,
216
+ 'libtensorflow.so.2' ,
217
+ 'libtensorflow.so' ,
218
+ )
219
+
220
+ for (index , value ) in enumerate (versions [:- 1 ]):
221
+ self ._symlink (value ,
222
+ os .path .join (self .install_toolchain_path (),
223
+ 'usr' , 'lib' , 'swift' , subdir ,
224
+ versions [index + 1 ]))
225
+ else :
226
+ self ._symlink (suffixed_lib_name ,
227
+ os .path .join (self .install_toolchain_path (),
228
+ 'usr' , 'lib' , 'swift' , subdir ,
229
+ unsuffixed_lib_name ))
215
230
216
231
try :
217
232
shutil .rmtree (os .path .join (self .install_toolchain_path (),
0 commit comments