@@ -47,6 +47,7 @@ class _Target(typing.Generic[_S, _R]):
4747    debug : bool  =  False 
4848    verbose : bool  =  False 
4949    known_symbols : dict [str , int ] =  dataclasses .field (default_factory = dict )
50+     pyconfig_dir : pathlib .Path  =  pathlib .Path .cwd ().resolve ()
5051
5152    def  _get_nop (self ) ->  bytes :
5253        if  re .fullmatch (r"aarch64-.*" , self .triple ):
@@ -57,13 +58,13 @@ def _get_nop(self) -> bytes:
5758            raise  ValueError (f"NOP not defined for { self .triple }  )
5859        return  nop 
5960
60-     def  _compute_digest (self ,  out :  pathlib . Path ) ->  str :
61+     def  _compute_digest (self ) ->  str :
6162        hasher  =  hashlib .sha256 ()
6263        hasher .update (self .triple .encode ())
6364        hasher .update (self .debug .to_bytes ())
6465        # These dependencies are also reflected in _JITSources in regen.targets: 
6566        hasher .update (PYTHON_EXECUTOR_CASES_C_H .read_bytes ())
66-         hasher .update ((out  /  "pyconfig.h" ).read_bytes ())
67+         hasher .update ((self . pyconfig_dir  /  "pyconfig.h" ).read_bytes ())
6768        for  dirpath , _ , filenames  in  sorted (os .walk (TOOLS_JIT )):
6869            for  filename  in  filenames :
6970                hasher .update (pathlib .Path (dirpath , filename ).read_bytes ())
@@ -125,7 +126,7 @@ async def _compile(
125126            f"-D_JIT_OPCODE={ opname }  ,
126127            "-D_PyJIT_ACTIVE" ,
127128            "-D_Py_JIT" ,
128-             "-I. " ,
129+             f "-I{ self . pyconfig_dir } 
129130            f"-I{ CPYTHON  /  'Include' }  ,
130131            f"-I{ CPYTHON  /  'Include'  /  'internal' }  ,
131132            f"-I{ CPYTHON  /  'Include'  /  'internal'  /  'mimalloc' }  ,
@@ -193,28 +194,27 @@ async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]:
193194
194195    def  build (
195196        self ,
196-         out : pathlib .Path ,
197197        * ,
198198        comment : str  =  "" ,
199199        force : bool  =  False ,
200-         stencils_h :  str   =   "jit_stencils.h" ,
200+         jit_stencils :  pathlib . Path ,
201201    ) ->  None :
202202        """Build jit_stencils.h in the given directory.""" 
203+         jit_stencils .parent .mkdir (parents = True , exist_ok = True )
203204        if  not  self .stable :
204205            warning  =  f"JIT support for { self .triple }  
205206            request  =  "Please report any issues you encounter." .center (len (warning ))
206207            outline  =  "="  *  len (warning )
207208            print ("\n " .join (["" , outline , warning , request , outline , "" ]))
208-         digest  =  f"// { self ._compute_digest (out )} \n " 
209-         jit_stencils  =  out  /  stencils_h 
209+         digest  =  f"// { self ._compute_digest ()} \n " 
210210        if  (
211211            not  force 
212212            and  jit_stencils .exists ()
213213            and  jit_stencils .read_text ().startswith (digest )
214214        ):
215215            return 
216216        stencil_groups  =  ASYNCIO_RUNNER .run (self ._build_stencils ())
217-         jit_stencils_new  =  out  /  "jit_stencils.h.new" 
217+         jit_stencils_new  =  jit_stencils . parent  /  "jit_stencils.h.new" 
218218        try :
219219            with  jit_stencils_new .open ("w" ) as  file :
220220                file .write (digest )
0 commit comments