diff --git a/cli/onionshare_cli/common.py b/cli/onionshare_cli/common.py
index 7cb61b86..724122b5 100644
--- a/cli/onionshare_cli/common.py
+++ b/cli/onionshare_cli/common.py
@@ -19,6 +19,7 @@ along with this program. If not, see .
"""
import base64
import hashlib
+import importlib.resources as importlib_resources
import os
import platform
import random
@@ -29,7 +30,6 @@ import threading
import time
import shutil
import re
-from pkg_resources import resource_filename
import colorama
from colorama import Fore, Back, Style
@@ -313,9 +313,10 @@ class Common:
"""
Returns the absolute path of a resource
"""
- path = resource_filename("onionshare_cli", os.path.join("resources", filename))
- self.log("Common", "get_resource_path", f"filename={filename}, path={path}")
- return path
+ ref = importlib_resources.files("onionshare_cli.resources") / filename
+ with importlib_resources.as_file(ref) as path:
+ self.log("Common", "get_resource_path", f"filename={filename}, path={str(path)}")
+ return str(path)
def get_tor_paths(self):
if self.platform == "Linux":
diff --git a/desktop/onionshare/gui_common.py b/desktop/onionshare/gui_common.py
index fcbf47f7..6e04c9f0 100644
--- a/desktop/onionshare/gui_common.py
+++ b/desktop/onionshare/gui_common.py
@@ -18,9 +18,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
"""
+import importlib.resources as importlib_resources
import os
import shutil
-from pkg_resources import resource_filename
from PySide6 import QtCore, QtWidgets, QtGui
from . import strings
@@ -548,8 +548,10 @@ class GuiCommon:
Returns the absolute path of a resource
"""
try:
- return resource_filename("onionshare", os.path.join("resources", filename))
- except KeyError:
+ ref = importlib_resources.files("onionshare.resources") / filename
+ with importlib_resources.as_file(ref) as path:
+ return str(path)
+ except FileNotFoundError:
return None
@staticmethod