@@ -154,11 +154,12 @@ def get_extensions():
154
154
extension (
155
155
'torchvision._C' ,
156
156
sources ,
157
- libraries = libraries ,
157
+ libraries = libraries ,
158
158
library_dirs = third_party_search_directories ,
159
159
include_dirs = include_dirs + third_party_search_directories ,
160
160
define_macros = define_macros ,
161
161
extra_compile_args = extra_compile_args ,
162
+ runtime_library_dirs = ['lib' ]
162
163
)
163
164
]
164
165
if compile_cpp_tests :
@@ -210,6 +211,7 @@ def run(self):
210
211
# It's an old-style class in Python 2.7...
211
212
distutils .command .clean .clean .run (self )
212
213
214
+
213
215
def throw_of_failure (command ):
214
216
ret = os .system (command )
215
217
if ret != 0 :
@@ -222,22 +224,31 @@ def build_deps():
222
224
cpu_count = multiprocessing .cpu_count ()
223
225
os .chdir ("third_party/zlib/" )
224
226
throw_of_failure ('cmake .' )
225
- throw_of_failure ("cmake --build . --parallel {}" .format (cpu_count ))
227
+ throw_of_failure ("cmake --build . -- -j {}" .format (cpu_count ))
226
228
os .chdir (this_dir )
227
229
228
230
zlib_path = os .path .join (this_dir , "third_party/zlib" )
229
- libpng_cmake_options = "-DPNG_BUILD_ZLIB=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR:PATH={zlib_path} -DZLIB_LIBRARY:FILEPATH={zlib_path}/libz.so" .format (zlib_path = zlib_path )
231
+ libpng_cmake_options = "-DPNG_BUILD_ZLIB=ON -DPNG_STATIC=OFF -DZLIB_INCLUDE_DIR:PATH={zlib_path} -DZLIB_LIBRARY:FILEPATH={zlib_path}/libz.so" .format (zlib_path = zlib_path )
230
232
os .chdir ("third_party/libpng/" )
231
233
os .system ('cmake {} .' .format (libpng_cmake_options ))
232
- throw_of_failure ("cmake --build . --parallel {}" .format (cpu_count ))
234
+ throw_of_failure ("cmake --build . -- -j {}" .format (cpu_count ))
233
235
os .chdir (this_dir )
234
236
235
237
236
-
237
238
def build_ext_with_dependencies (self ):
238
239
build_deps ()
239
240
return BuildExtension .with_options (no_python_abi_suffix = True )(self )
240
241
242
+
243
+ data_files = []
244
+ if sys .platform .startswith ('linux' ):
245
+ data_files = [
246
+ ('torchvision/lib' , [
247
+ 'third_party/zlib/libz.so' ,
248
+ 'third_party/libpng/libpng.so' ])
249
+ ]
250
+
251
+
241
252
setup (
242
253
# Metadata
243
254
name = package_name ,
@@ -261,5 +272,6 @@ def build_ext_with_dependencies(self):
261
272
cmdclass = {
262
273
'build_ext' : build_ext_with_dependencies ,
263
274
'clean' : clean ,
264
- }
275
+ },
276
+ data_files = data_files
265
277
)
0 commit comments