2727from mypyc .options import CompilerOptions
2828from mypyc .test .config import test_data_prefix
2929from mypyc .test .test_serialization import check_serialization_roundtrip
30+ from mypyc .test .librt_cache import get_librt_path
3031from mypyc .test .testutil import (
3132 ICODE_GEN_BUILTINS ,
3233 TESTUTIL_PATH ,
@@ -289,6 +290,7 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) ->
289290
290291 setup_file = os .path .abspath (os .path .join (WORKDIR , "setup.py" ))
291292 # We pass the C file information to the build script via setup.py unfortunately
293+ # Note: install_librt is always False since we use cached librt from librt_cache
292294 with open (setup_file , "w" , encoding = "utf-8" ) as f :
293295 f .write (
294296 setup_format .format (
@@ -297,16 +299,15 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) ->
297299 (cfiles , deps ),
298300 self .multi_file ,
299301 opt_level ,
300- librt ,
302+ False , # install_librt - use cached version instead
301303 experimental_features ,
302304 )
303305 )
304306
305307 if librt :
306- # This hack forces Python to prefer the local "installation".
307- os .makedirs ("librt" , exist_ok = True )
308- with open (os .path .join ("librt" , "__init__.py" ), "a" ):
309- pass
308+ # Use cached pre-built librt instead of rebuilding for each test
309+ cached_librt = get_librt_path (experimental_features )
310+ shutil .copytree (os .path .join (cached_librt , "librt" ), "librt" )
310311
311312 if not run_setup (setup_file , ["build_ext" , "--inplace" ]):
312313 if testcase .config .getoption ("--mypyc-showc" ):
0 commit comments