@@ -225,12 +225,18 @@ def clear_cache(self):
225225 self ._raw_cache = {}
226226 self ._dirty_cache = True
227227
228- def query_install (self , exe_path : str , managed_by : str | None = None ) -> PythonInstall | None :
228+ def query_install (
229+ self ,
230+ exe_path : str ,
231+ managed_by : str | None = None ,
232+ metadata : dict | None = None ,
233+ ) -> PythonInstall | None :
229234 """
230235 Query the details of a Python install directly
231236
232237 :param exe_path: Path to the runtime .exe
233238 :param managed_by: Which tool manages this install (if any)
239+ :param metadata: Dictionary of install metadata
234240 :return: a PythonInstall if one exists at the exe Path
235241 """
236242 try :
@@ -273,9 +279,19 @@ def query_install(self, exe_path: str, managed_by: str | None = None) -> PythonI
273279 except _laz .json .JSONDecodeError :
274280 return None
275281
276- return PythonInstall .from_json (** output , managed_by = managed_by )
282+ if metadata :
283+ output ["metadata" ].update (metadata )
284+
285+ install = PythonInstall .from_json (** output , managed_by = managed_by )
277286
278- def get_install_details (self , exe_path : str , managed_by = None ) -> PythonInstall | None :
287+ return install
288+
289+ def get_install_details (
290+ self ,
291+ exe_path : str ,
292+ managed_by : str | None = None ,
293+ metadata : dict | None = None ,
294+ ) -> PythonInstall | None :
279295 exe_path = os .path .abspath (exe_path )
280296 mtime = os .stat (exe_path ).st_mtime
281297
@@ -287,7 +303,7 @@ def get_install_details(self, exe_path: str, managed_by=None) -> PythonInstall |
287303 self .raw_cache .pop (exe_path )
288304
289305 if install is None :
290- install = self .query_install (exe_path , managed_by )
306+ install = self .query_install (exe_path , managed_by , metadata )
291307 if install :
292308 self .raw_cache [exe_path ] = {
293309 "mtime" : mtime ,
@@ -416,6 +432,7 @@ def get_folder_pythons(
416432 base_folder : str | os .PathLike ,
417433 basenames : tuple [str ] = ("python" , "pypy" ),
418434 finder : DetailFinder | None = None ,
435+ managed_by : str | None = None ,
419436):
420437 regexes = [_python_exe_regex (name ) for name in basenames ]
421438
@@ -440,7 +457,7 @@ def get_folder_pythons(
440457 continue
441458 else :
442459 p = file_path .path
443- install = finder .get_install_details (p )
460+ install = finder .get_install_details (p , managed_by = managed_by )
444461 if install :
445462 yield install
446463
@@ -483,7 +500,6 @@ def get_uv_python_path() -> str | None:
483500
484501def _implementation_from_uv_dir (
485502 direntry : os .DirEntry ,
486- query_executables : bool = True ,
487503 finder : DetailFinder | None = None ,
488504) -> PythonInstall | None :
489505 python_exe = "python.exe" if sys .platform == "win32" else "bin/python"
@@ -493,35 +509,12 @@ def _implementation_from_uv_dir(
493509 finder = DetailFinder () if finder is None else finder
494510
495511 if os .path .exists (python_path ):
496- if match := _laz .re .fullmatch (UV_PYTHON_RE , direntry .name ):
497- implementation , version , extra , platform , arch = match .groups ()
498- metadata = {
499- "freethreaded" : "freethreaded" in extra ,
500- }
501-
502- try :
503- if implementation in {"cpython" }:
504- install = PythonInstall .from_str (
505- version = version ,
506- executable = python_path ,
507- architecture = "32bit" if arch in {"i686" , "armv7" } else "64bit" ,
508- implementation = implementation ,
509- metadata = metadata ,
510- managed_by = "Astral" ,
511- )
512- except ValueError :
513- pass
514-
515- if install is None :
516- # Directory name format has changed or this is an alternate implementation
517- # Slow backup - ask python itself
518- if query_executables :
519- install = finder .get_install_details (python_path , managed_by = "Astral" )
512+ install = finder .get_install_details (python_path , managed_by = "Astral" )
520513
521514 return install
522515
523516
524- def get_uv_pythons (query_executables = True , finder = None ) -> Iterator [PythonInstall ]:
517+ def get_uv_pythons (finder = None ) -> Iterator [PythonInstall ]:
525518 # This takes some shortcuts over the regular pythonfinder
526519 # As the UV folders give the python version and the implementation
527520 if uv_python_path := get_uv_python_path ():
@@ -532,6 +525,6 @@ def get_uv_pythons(query_executables=True, finder=None) -> Iterator[PythonInstal
532525 for f in fld :
533526 if (
534527 f .is_dir ()
535- and (install := _implementation_from_uv_dir (f , query_executables , finder = finder ))
528+ and (install := _implementation_from_uv_dir (f , finder = finder ))
536529 ):
537530 yield install
0 commit comments