@@ -68,7 +68,7 @@ def run(self):
68
68
super ().run ()
69
69
70
70
def build_extension (self , ext ):
71
- """Call our CMake build system to build libtorchcodec? .so"""
71
+ """Call our CMake build system to build libtorchcodec* .so"""
72
72
# Setuptools was designed to build one extension (.so file) at a time,
73
73
# calling this method for each Extension object. We're using a
74
74
# CMake-based build where all our extensions are built together at once.
@@ -136,21 +136,27 @@ def copy_extensions_to_source(self):
136
136
This is called by setuptools at the end of .run() during editable installs.
137
137
"""
138
138
self .get_finalized_command ("build_py" )
139
- extension = ""
139
+ extensions = []
140
140
if sys .platform == "linux" :
141
- extension = "so"
141
+ extensions = [ "so" ]
142
142
elif sys .platform == "darwin" :
143
- extension = "dylib"
143
+ # Mac has BOTH .dylib and .so as library extensions. Short version
144
+ # is that a .dylib is a shared library that can be both dynamically
145
+ # loaded and depended on by other libraries; a .so can only be a
146
+ # dynamically loaded module. For more, see:
147
+ # https://stackoverflow.com/a/2339910
148
+ extensions = ["dylib" , "so" ]
144
149
else :
145
150
raise NotImplementedError (
146
151
"Platforms other than linux/darwin are not supported yet"
147
152
)
148
153
149
- for so_file in self ._install_prefix .glob (f"*.{ extension } " ):
150
- assert "libtorchcodec" in so_file .name
151
- destination = Path ("src/torchcodec/" ) / so_file .name
152
- print (f"Copying { so_file } to { destination } " )
153
- self .copy_file (so_file , destination , level = self .verbose )
154
+ for ext in extensions :
155
+ for lib_file in self ._install_prefix .glob (f"*.{ ext } " ):
156
+ assert "libtorchcodec" in lib_file .name
157
+ destination = Path ("src/torchcodec/" ) / lib_file .name
158
+ print (f"Copying { lib_file } to { destination } " )
159
+ self .copy_file (lib_file , destination , level = self .verbose )
154
160
155
161
156
162
NOT_A_LICENSE_VIOLATION_VAR = "I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION"
0 commit comments