Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depends on deprecated pkg_resources module #112

Open
emollier opened this issue Oct 16, 2024 · 0 comments
Open

depends on deprecated pkg_resources module #112

emollier opened this issue Oct 16, 2024 · 0 comments

Comments

@emollier
Copy link

Hi,

As initially reported in Debian bug #1083762, scoary depends on pkg_resources which is deprecated and on a course to be removed. I intend to workaround the issue with the below patch, but I'm not 100% it is suitable in every situations, notably outside Debian context. Anyway, in case you find something useful:

--- scoary.orig/scoary/GUI.py
+++ scoary/scoary/GUI.py
@@ -61,7 +61,7 @@
 except ImportError:
     sys.exit("Could not find the main Scoary executable") 
 
-from pkg_resources import resource_string, resource_filename
+from importlib.metadata import distribution
 
 class ScoaryGUI(Tkinter.Tk):
     """
@@ -617,11 +617,12 @@
         """
         Sets all variables corresponding to --test in the methods script
         """
+        scoary_dist = distribution('scoary')
         self.GPAentryVariable.set(
-            str(os.path.join(resource_filename(__name__, 'exampledata'),
+            str(os.path.join(scoary_dist.locate_file('scoary'), 'exampledata',
                              'Gene_presence_absence.csv')))
         self.TraitsentryVariable.set(
-            str(os.path.join(resource_filename(__name__, 'exampledata'),
+            str(os.path.join(scoary_dist.locate_file('scoary'), 'exampledata',
                              'Tetracycline_resistance.csv')))
         self.TreeentryVariable.set("")
         self.RestrictVariable.set("")
--- scoary.orig/scoary/methods.py
+++ scoary/scoary/methods.py
@@ -27,7 +27,7 @@
 #import scoary
 
 import os
-from pkg_resources import resource_string, resource_filename
+from importlib.metadata import distribution
 
 #SCOARY_VERSION = scoary.__version__
 SCOARY_VERSION = __version__
@@ -69,9 +69,10 @@
     if args.test:
         args.correction = ['I','EPW']
         args.delimiter = ','
-        args.genes = os.path.join(
-            resource_filename(__name__, 'exampledata'), 
-            'Gene_presence_absence.csv')
+        scoary_dist = distribution('scoary')
+        args.genes = os.path.join(scoary_dist.locate_file('scoary'),
+                                  'exampledata',
+                                  'Gene_presence_absence.csv')
         args.grabcols = []
         args.max_hits = None
         args.newicktree = None
@@ -82,9 +83,9 @@
         args.restrict_to = None
         args.start_col = 15
         args.threads = 4
-        args.traits = os.path.join(
-            resource_filename(__name__, 'exampledata'),
-            'Tetracycline_resistance.csv')
+        args.traits = os.path.join(scoary_dist.locate_file('scoary'),
+                                   'exampledata',
+                                   'Tetracycline_resistance.csv')
         args.upgma_tree = True
         args.write_reduced = False
         args.no_time = False

Have a nice day, :)
Étienne.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant