Skip to content

Commit

Permalink
remove usage of pkg_resources (#572)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
Javagedes authored May 30, 2024
1 parent 474d99b commit 5b1c468
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions edk2toollib/windows/locate_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
NOTE: Has the capability to download VSwhere.
"""
import glob
import importlib.resources as resources
import logging
import os
import re
import subprocess
from pathlib import Path
from typing import List, Optional

import pkg_resources

from edk2toollib.utility_functions import GetHostInfo, RunCmd

try:
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 5b1c468

Please sign in to comment.