@@ -93,13 +93,13 @@ def get_extensions():
93
93
extra_compile_args = {}
94
94
third_party_search_directories = []
95
95
96
-
97
- runtime_library_dirs = None
96
+ extra_objects = []
98
97
if sys .platform .startswith ('linux' ):
99
98
sources = sources + source_image_cpu
100
99
libraries .append ('png' )
101
100
third_party_search_directories .append (os .path .join (cwd , "third_party/libpng" ))
102
101
runtime_library_dirs = ['lib' ]
102
+ extra_objects = ['third_party/zlib/libz.a' , 'third_party/libpng/libpng.a' ]
103
103
104
104
extension = CppExtension
105
105
@@ -117,7 +117,6 @@ def get_extensions():
117
117
118
118
define_macros = []
119
119
120
- extra_compile_args = {}
121
120
if (torch .cuda .is_available () and CUDA_HOME is not None ) or os .getenv ('FORCE_CUDA' , '0' ) == '1' :
122
121
extension = CUDAExtension
123
122
sources += source_cuda
@@ -162,7 +161,7 @@ def get_extensions():
162
161
include_dirs = include_dirs + third_party_search_directories ,
163
162
define_macros = define_macros ,
164
163
extra_compile_args = extra_compile_args ,
165
- runtime_library_dirs = runtime_library_dirs
164
+ extra_objects = extra_objects
166
165
)
167
166
]
168
167
if compile_cpp_tests :
@@ -231,9 +230,9 @@ def build_deps():
231
230
os .chdir (this_dir )
232
231
233
232
zlib_path = os .path .join (this_dir , "third_party/zlib" )
234
- 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 )
233
+ libpng_cmake_options = "-DPNG_BUILD_ZLIB=ON -DPNG_STATIC=ON -DZLIB_INCLUDE_DIR:PATH={zlib_path} -DZLIB_LIBRARY:FILEPATH={zlib_path}/libz.so" .format (zlib_path = zlib_path )
235
234
os .chdir ("third_party/libpng/" )
236
- os .system ('cmake {} .' .format (libpng_cmake_options ))
235
+ os .system ('cmake -DCMAKE_C_FLAGS="-fPIC" {} .' .format (libpng_cmake_options ))
237
236
throw_of_failure ("cmake --build . -- -j {}" .format (cpu_count ))
238
237
os .chdir (this_dir )
239
238
@@ -243,15 +242,6 @@ def build_ext_with_dependencies(self):
243
242
return BuildExtension .with_options (no_python_abi_suffix = True )(self )
244
243
245
244
246
- data_files = []
247
- if sys .platform .startswith ('linux' ):
248
- data_files = [
249
- ('torchvision/lib' , [
250
- 'third_party/zlib/libz.so' ,
251
- 'third_party/libpng/libpng.so' ])
252
- ]
253
-
254
-
255
245
setup (
256
246
# Metadata
257
247
name = package_name ,
@@ -276,5 +266,4 @@ def build_ext_with_dependencies(self):
276
266
'build_ext' : build_ext_with_dependencies ,
277
267
'clean' : clean ,
278
268
},
279
- data_files = data_files
280
269
)
0 commit comments