File: remove-pkg-resources-usage.patch

package info (click to toggle)
tombo 1.5.1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,140 kB
  • sloc: python: 12,433; sh: 613; makefile: 16
file content (146 lines) | stat: -rw-r--r-- 7,061 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Description: replace deprecated pkg_resources usage with importlib
Author: Ananthu C V <weepingclown@debian.org>
Bug-Debian: https://bugs.debian.org/1083801
Last-Update: 2024-11-28
--- a/tombo/_plot_commands.py
+++ b/tombo/_plot_commands.py
@@ -20,3 +20,3 @@
 from itertools import repeat, groupby
-from pkg_resources import resource_string
+from importlib.resources import files
 
@@ -169,3 +169,3 @@
         'Comparison':r.StrVector(mod_names_for_r)})
-    r.r(resource_string(__name__, 'R_scripts/plotROC.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotROC.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=4, width=6)')
@@ -237,3 +237,3 @@
         'Comparison':r.StrVector(mod_names_for_r)})
-    r.r(resource_string(__name__, 'R_scripts/plotROC.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotROC.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=4, width=6)')
@@ -342,3 +342,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotROCPerRead.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotROCPerRead.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=4, width=6)')
@@ -437,3 +437,3 @@
         'Comparison':r.StrVector(mod_names_for_r)})
-    r.r(resource_string(__name__, 'R_scripts/plotROCPerRead.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotROCPerRead.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=4, width=6)')
@@ -548,3 +548,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotKmerDist.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotKmerDist.R').read_bytes().decode())
     if not dont_plot: r.r('pdf("' + pdf_fn + '", height=7, width=10)')
@@ -629,3 +629,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotSingleRead.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotSingleRead.R').read_bytes().decode())
     r.r('png("' + png_fn + '", width=3000, height=1400)')
@@ -1141,3 +1141,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotReadCorr.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotReadCorr.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=7, width=11)')
@@ -1240,3 +1240,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotMultiReadCorr.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotMultiReadCorr.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=11)')
@@ -1353,3 +1353,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotSingleRun.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotSingleRun.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=11)')
@@ -1411,3 +1411,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotGroupComp.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotGroupComp.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=11)')
@@ -1579,3 +1579,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotMotifStats.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotMotifStats.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=8)')
@@ -1613,3 +1613,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotModelComp.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotModelComp.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=11)')
@@ -1645,3 +1645,3 @@
     if VERBOSE: th.status_message('Plotting.')
-    r.r(resource_string(__name__, 'R_scripts/plotPerReadStats.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotPerReadStats.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=5, width=11)')
@@ -2219,3 +2219,3 @@
     if VERBOSE: th.status_message('Plotting (and saving data).')
-    r.r(resource_string(__name__, 'R_scripts/plotSigMDS.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/plotSigMDS.R').read_bytes().decode())
     r.r('pdf("' + pdf_fn + '", height=7, width=7)')
--- a/tombo/resquiggle.py
+++ b/tombo/resquiggle.py
@@ -37,3 +37,3 @@
 from collections import defaultdict
-from pkg_resources import resource_string
+from importlib.resources import files
 
@@ -199,3 +199,3 @@
 
-    r.r(resource_string(__name__, 'R_scripts/debugDP.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/debugDP.R').read_bytes().decode())
     r.globalenv[str('plotDP')](dpDat, tbDat)
@@ -247,3 +247,3 @@
 
-    r.r(resource_string(__name__, 'R_scripts/debugRawDP.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/debugRawDP.R').read_bytes().decode())
     r.globalenv[str('plotRawDP')](zDat, fwdDat, tbDat, sigDat)
@@ -302,3 +302,3 @@
 
-    r.r(resource_string(__name__, 'R_scripts/debugFit.R').decode())
+    r.r(files(__name__).joinpath('R_scripts/debugFit.R').read_bytes().decode())
     r.globalenv[str('plotFit')](fitDat, bandwidth)
--- a/tombo/tombo_stats.py
+++ b/tombo/tombo_stats.py
@@ -10,3 +10,3 @@
 import random
-import pkg_resources
+
 
@@ -31,2 +31,3 @@
 from itertools import repeat, product, count, combinations
+from importlib.resources import files
 
@@ -723,4 +724,3 @@
         # get full filename path with setuptools
-        self.ref_fn = th.resolve_path(pkg_resources.resource_filename(
-            'tombo', 'tombo_models/' + std_ref_fn))
+        self.ref_fn = th.resolve_path(files('tombo')/'tombo_models'/std_ref_fn)
 
@@ -740,4 +740,3 @@
         # get full filename path with setuptools
-        self.ref_fn = th.resolve_path(pkg_resources.resource_filename(
-            'tombo', 'tombo_models/' + std_ref_fn))
+        self.ref_fn = th.resolve_path(files('tombo')/'tombo_models'/std_ref_fn)
 
@@ -797,5 +796,3 @@
                 self.seq_samp_type = seq_samp_type
-                self.ref_fn = th.resolve_path(pkg_resources.resource_filename(
-                    'tombo', 'tombo_models/' + STANDARD_MODELS[
-                        seq_samp_type.name]))
+                self.ref_fn = th.resolve_path(files('tombo')/'tombo_models'/STANDARD_MODELS[seq_samp_type.name])
             elif reads_index is not None:
@@ -1171,4 +1168,3 @@
         # get full filename path with setuptools
-        alt_model_fn = pkg_resources.resource_filename(
-            'tombo', 'tombo_models/' + alt_model_fn)
+        alt_model_fn = (files('tombo')/'tombo_models'/alt_model_fn).as_posix()
     if alt_model_fn is None or not os.path.isfile(alt_model_fn):
--- a/setup.py
+++ b/setup.py
@@ -59,3 +59,3 @@
     install_requires = ['h5py', 'numpy', 'scipy',
-                        'setuptools >= 18.0', 'mappy >= 2.10', 'tqdm'],
+                        'mappy >= 2.10', 'tqdm'],
     extras_require={'full':extras_require},