@@ -68,7 +68,7 @@ def run(self):
6868 super ().run ()
6969
7070 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"""
7272 # Setuptools was designed to build one extension (.so file) at a time,
7373 # calling this method for each Extension object. We're using a
7474 # CMake-based build where all our extensions are built together at once.
@@ -136,21 +136,27 @@ def copy_extensions_to_source(self):
136136 This is called by setuptools at the end of .run() during editable installs.
137137 """
138138 self .get_finalized_command ("build_py" )
139- extension = ""
139+ extensions = []
140140 if sys .platform == "linux" :
141- extension = "so"
141+ extensions = [ "so" ]
142142 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" ]
144149 else :
145150 raise NotImplementedError (
146151 "Platforms other than linux/darwin are not supported yet"
147152 )
148153
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 )
154160
155161
156162NOT_A_LICENSE_VIOLATION_VAR = "I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION"
0 commit comments