@@ -96,7 +96,11 @@ def interpose_sccache():
9696 return
9797
9898 # Check for sccache. We don't do multi-step failover (e.g., if ${SCCACHE_PATH} is set, but the binary is invalid)
99- sccache_path = Path (os .getenv ("SCCACHE_PATH" , shutil .which ("sccache" )))
99+ _sccache_path = os .getenv ("SCCACHE_PATH" , shutil .which ("sccache" ))
100+ if _sccache_path is None :
101+ print ("WARNING: SCCACHE_PATH is not set, skipping sccache interposition" )
102+ return
103+ sccache_path = Path (_sccache_path )
100104 if sccache_path .is_file () and os .access (sccache_path , os .X_OK ):
101105 # Both the cmake and rust toolchains allow the caller to interpose sccache into the compiler commands, but this
102106 # misses calls from native extension builds. So we do the normal Rust thing, but modify CC and CXX to point to
@@ -159,7 +163,11 @@ def load_module_from_project_file(mod_name, fname):
159163 import importlib .util
160164
161165 spec = importlib .util .spec_from_file_location (mod_name , fpath )
166+ if spec is None :
167+ raise ImportError (f"Could not find module { mod_name } in { fpath } " )
162168 mod = importlib .util .module_from_spec (spec )
169+ if spec .loader is None :
170+ raise ImportError (f"Could not load module { mod_name } from { fpath } " )
163171 spec .loader .exec_module (mod )
164172 return mod
165173
@@ -195,12 +203,12 @@ class LibraryDownload:
195203 USE_CACHE = os .getenv ("DD_SETUP_CACHE_DOWNLOADS" , "0" ).lower () in ("1" , "yes" , "on" , "true" )
196204
197205 name = None
198- download_dir = None
206+ download_dir = Path . cwd ()
199207 version = None
200208 url_root = None
201- available_releases = None
209+ available_releases = {}
202210 expected_checksums = None
203- translate_suffix = None
211+ translate_suffix = {}
204212
205213 @classmethod
206214 def download_artifacts (cls ):
@@ -221,7 +229,7 @@ def download_artifacts(cls):
221229 # https://github.com/pypa/cibuildwheel/blob/main/cibuildwheel/macos.py#L250
222230 target_platform = os .getenv ("PLAT" )
223231 # Darwin Universal2 should bundle both architectures
224- if not target_platform .endswith (("universal2" , arch )):
232+ if target_platform and not target_platform .endswith (("universal2" , arch )):
225233 continue
226234 elif CURRENT_OS == "Windows" and (not is_64_bit_python () != arch .endswith ("32" )):
227235 # Win32 can be built on a 64-bit machine so build_platform may not be relevant
@@ -242,7 +250,7 @@ def download_artifacts(cls):
242250 archive_name ,
243251 )
244252
245- download_dest = cls .CACHE_DIR / archive_name if cls .USE_CACHE else archive_name
253+ download_dest = cls .CACHE_DIR / archive_name if cls .USE_CACHE else Path ( archive_name )
246254 if cls .USE_CACHE and not cls .CACHE_DIR .exists ():
247255 cls .CACHE_DIR .mkdir (parents = True )
248256
@@ -296,6 +304,10 @@ def download_artifacts(cls):
296304 def run (cls ):
297305 cls .download_artifacts ()
298306
307+ @classmethod
308+ def get_package_name (cls , arch , os ) -> str :
309+ raise NotImplementedError ()
310+
299311 @classmethod
300312 def get_archive_name (cls , arch , os ):
301313 return cls .get_package_name (arch , os ) + ".tar.gz"
@@ -314,13 +326,13 @@ class LibDDWafDownload(LibraryDownload):
314326 translate_suffix = {"Windows" : (".dll" ,), "Darwin" : (".dylib" ,), "Linux" : (".so" ,)}
315327
316328 @classmethod
317- def get_package_name (cls , arch , opsys ):
318- archive_dir = "lib%s-%s-%s-%s" % (cls .name , cls .version , opsys .lower (), arch )
329+ def get_package_name (cls , arch , os ):
330+ archive_dir = "lib%s-%s-%s-%s" % (cls .name , cls .version , os .lower (), arch )
319331 return archive_dir
320332
321333 @classmethod
322- def get_archive_name (cls , arch , opsys ):
323- os_name = opsys .lower ()
334+ def get_archive_name (cls , arch , os ):
335+ os_name = os .lower ()
324336 if os_name == "linux" :
325337 archive_dir = "lib%s-%s-%s-linux-musl.tar.gz" % (cls .name , cls .version , arch )
326338 else :
@@ -594,7 +606,7 @@ class CMakeExtension(Extension):
594606 def __init__ (
595607 self ,
596608 name ,
597- source_dir = Path ( "." ),
609+ source_dir = Path . cwd ( ),
598610 cmake_args = [],
599611 build_args = [],
600612 install_args = [],
@@ -656,12 +668,13 @@ def check_rust_toolchain():
656668DD_BUILD_EXT_EXCLUDES = [_ .strip () for _ in os .getenv ("DD_BUILD_EXT_EXCLUDES" , "" ).split ("," ) if _ .strip ()]
657669
658670
659- def filter_extensions (extensions ):
660- # type: (list[Extension]) -> list[Extension]
671+ def filter_extensions (
672+ extensions : t .List [t .Union [Extension , Cython .Distutils .Extension , RustExtension ]],
673+ ) -> t .List [t .Union [Extension , Cython .Distutils .Extension , RustExtension ]]:
661674 if not DD_BUILD_EXT_INCLUDES and not DD_BUILD_EXT_EXCLUDES :
662675 return extensions
663676
664- filtered : list [ Extension ] = []
677+ filtered : t . List [ t . Union [ Extension , Cython . Distutils . Extension , RustExtension ] ] = []
665678 for ext in extensions :
666679 if DD_BUILD_EXT_EXCLUDES and any (fnmatch .fnmatch (ext .name , pattern ) for pattern in DD_BUILD_EXT_EXCLUDES ):
667680 print (f"INFO: Excluding extension { ext .name } " )
@@ -693,12 +706,6 @@ def get_exts_for(name):
693706 return []
694707
695708
696- if sys .byteorder == "big" :
697- encoding_macros = [("__BIG_ENDIAN__" , "1" )]
698- else :
699- encoding_macros = [("__LITTLE_ENDIAN__" , "1" )]
700-
701-
702709if CURRENT_OS == "Windows" :
703710 encoding_libraries = ["ws2_32" ]
704711 extra_compile_args = []
@@ -727,7 +734,7 @@ def get_exts_for(name):
727734
728735
729736if not IS_PYSTON :
730- ext_modules = [
737+ ext_modules : t . List [ t . Union [ Extension , Cython . Distutils . Extension , RustExtension ]] = [
731738 Extension (
732739 "ddtrace.profiling.collector._memalloc" ,
733740 sources = [
@@ -858,7 +865,7 @@ def get_exts_for(name):
858865 ["ddtrace/internal/_encoding.pyx" ],
859866 include_dirs = ["." ],
860867 libraries = encoding_libraries ,
861- define_macros = encoding_macros ,
868+ define_macros = [( f"__ { sys . byteorder . upper () } _ENDIAN__" , "1" )] ,
862869 ),
863870 Extension (
864871 "ddtrace.internal.telemetry.metrics_namespaces" ,
0 commit comments