From 5b1c468ee27e2dc806f86002a90e545ebff88ee1 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Thu, 30 May 2024 09:40:23 -0700 Subject: [PATCH] remove usage of `pkg_resources` (#572) `pkg_resources` module included with setuptools has been depreciated and now removed in python 3.12, resulting in import errors when using locate_tools functionality on 3.12. This change resolves the issue by using `importlib.resources` in it's place. --- edk2toollib/windows/locate_tools.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/edk2toollib/windows/locate_tools.py b/edk2toollib/windows/locate_tools.py index 7094121a..e67c476e 100644 --- a/edk2toollib/windows/locate_tools.py +++ b/edk2toollib/windows/locate_tools.py @@ -21,6 +21,7 @@ NOTE: Has the capability to download VSwhere. """ import glob +import importlib.resources as resources import logging import os import re @@ -28,8 +29,6 @@ from pathlib import Path from typing import List, Optional -import pkg_resources - from edk2toollib.utility_functions import GetHostInfo, RunCmd try: @@ -86,10 +85,7 @@ def _DownloadVsWhere(unpack_folder: os.PathLike = None) -> None: def __VsWherePath() -> str: file = "vswhere.exe" - requirement = pkg_resources.Requirement.parse("edk2-pytool-library") - file_path = os.path.join("edk2toollib", "bin", file) - vswhere_path = pkg_resources.resource_filename(requirement, file_path) - return vswhere_path + return str(resources.files("edk2toollib") / "bin" / file) def GetVsWherePath(fail_on_not_found: bool = True) -> Optional[str]: