tianocore / edk2-edkrepo

Repository for the edkrepo utility
Other
21 stars 24 forks source link

Installation Error: ModuleNotFoundError: No module named 'pkg_resources' with Windows Python 3.12.x #211

Closed ndhaller closed 2 months ago

ndhaller commented 7 months ago

Windows OS with python-3.12.0-amd64 or python-3.12.1-amd64 installed, EdkRepoSetup-3.1.3.0.exe Windows installer fails.

Found Python 3.12.1
...
C:\Program Files\Git\etc\profile.d\edkrepo_completions.sh
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\WINDOWS\edkrepo.exe\__main__.py", line 4, in <module>
File "C:\Python312\Lib\site-packages\edkrepo\edkrepo_entry_point.py", line 16, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Installation Error:
System.InvalidOperationException: generate-command-completion-script failed with status 1
at TianoCore.EdkRepoInstaller.InstallWorker.PerformInstall(Action`2 ReportComplete, Action`1 ReportProgress, Action`1 AllowCancel, Func`1 CancelPending)
at TianoCore.EdkRepoInstaller.ProgressWindow.WorkerThread()
Installation Failed.

Windows Python 3.12.x seems removed setuptools . Manually installing setuptools is now a Windows Install Pre-Requisite as well, not just for Linux Build.

py -3 -m pip install setuptools

ndhaller commented 4 months ago

edkrepo 3.2.2 , Python 3.12.3, setuptools==69.5.1

Seing a DeprcationWarning in edkrepo_cli.py with this configuration.

edk2-edkrepo\edkrepo_cli.py:14: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources

Is it possible to remove the pkg_resources use entirely?

-import pkg_resources
+from importlib.metadata import version
-        version = pkg_resources.get_distribution("edkrepo").version
-        parser.add_argument("--version", action="version", version="%(prog)s {0}".format(version))
+        edkrepo_version = version("edkrepo")
+        parser.add_argument("--version", action="version", version="%(prog)s {0}".format(edkrepo_version))