File: distutils-deprecation.patch

package info (click to toggle)
python-bcbio-gff 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 336 kB
  • sloc: python: 1,759; sh: 13; makefile: 6
file content (292 lines) | stat: -rw-r--r-- 10,353 bytes parent folder | download
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
Description: migrate away from distutils.
 Following [PEP 632], the distutils module is deprecated.  In bcbio.gff,
 this module is still in use for it's logging facility, so a
 contemporary approach would be to use the "logging" module instead of
 distutils.  logging.warning behaves essentially the same way as
 distutils.log.warn; there was also a logging.warn function but it is
 deprecated in favor of warning, thus this patch does not attempt to do
 something smart with things allowed by the import semantics.
 .
 [PEP 632]: https://peps.python.org/pep-0632/

Author: Étienne Mollier <emollier@debian.org>
Forwarded: https://github.com/chapmanb/bcbb/pull/146
Last-Update: 2024-11-05
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- python-bcbio-gff.orig/distribute_setup.py
+++ python-bcbio-gff/distribute_setup.py
@@ -21,8 +21,7 @@
 import tempfile
 import tarfile
 import optparse
-
-from distutils import log
+import logging
 
 try:
     from site import USER_SITE
@@ -69,7 +68,7 @@
 def _install(tarball, install_args=()):
     # extracting the tarball
     tmpdir = tempfile.mkdtemp()
-    log.warn('Extracting in %s', tmpdir)
+    logging.warning('Extracting in %s', tmpdir)
     old_wd = os.getcwd()
     try:
         os.chdir(tmpdir)
@@ -80,13 +79,13 @@
         # going in the directory
         subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
         os.chdir(subdir)
-        log.warn('Now working in %s', subdir)
+        logging.warning('Now working in %s', subdir)
 
         # installing
-        log.warn('Installing Distribute')
+        logging.warning('Installing Distribute')
         if not _python_cmd('setup.py', 'install', *install_args):
-            log.warn('Something went wrong during the installation.')
-            log.warn('See the error message above.')
+            logging.warning('Something went wrong during the installation.')
+            logging.warning('See the error message above.')
             # exitcode will be 2
             return 2
     finally:
@@ -97,7 +96,7 @@
 def _build_egg(egg, tarball, to_dir):
     # extracting the tarball
     tmpdir = tempfile.mkdtemp()
-    log.warn('Extracting in %s', tmpdir)
+    logging.warning('Extracting in %s', tmpdir)
     old_wd = os.getcwd()
     try:
         os.chdir(tmpdir)
@@ -108,17 +107,17 @@
         # going in the directory
         subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
         os.chdir(subdir)
-        log.warn('Now working in %s', subdir)
+        logging.warning('Now working in %s', subdir)
 
         # building an egg
-        log.warn('Building a Distribute egg in %s', to_dir)
+        logging.warning('Building a Distribute egg in %s', to_dir)
         _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
 
     finally:
         os.chdir(old_wd)
         shutil.rmtree(tmpdir)
     # returning the result
-    log.warn(egg)
+    logging.warning(egg)
     if not os.path.exists(egg):
         raise IOError('Could not build the egg.')
 
@@ -207,7 +206,7 @@
     src = dst = None
     if not os.path.exists(saveto):  # Avoid repeated downloads
         try:
-            log.warn("Downloading %s", url)
+            logging.warning("Downloading %s", url)
             src = urlopen(url)
             # Read/write all in one block, so we don't create a corrupt file
             # if the download is interrupted.
@@ -254,9 +253,9 @@
     f.close()
     if existing_content == content:
         # already patched
-        log.warn('Already patched.')
+        logging.warning('Already patched.')
         return False
-    log.warn('Patching...')
+    logging.warning('Patching...')
     _rename_path(path)
     f = open(path, 'w')
     try:
@@ -277,14 +276,14 @@
 
 def _rename_path(path):
     new_name = path + '.OLD.%s' % time.time()
-    log.warn('Renaming %s to %s', path, new_name)
+    logging.warning('Renaming %s to %s', path, new_name)
     os.rename(path, new_name)
     return new_name
 
 
 def _remove_flat_installation(placeholder):
     if not os.path.isdir(placeholder):
-        log.warn('Unkown installation at %s', placeholder)
+        logging.warning('Unkown installation at %s', placeholder)
         return False
     found = False
     for file in os.listdir(placeholder):
@@ -292,10 +291,10 @@
             found = True
             break
     if not found:
-        log.warn('Could not locate setuptools*.egg-info')
+        logging.warning('Could not locate setuptools*.egg-info')
         return
 
-    log.warn('Moving elements out of the way...')
+    logging.warning('Moving elements out of the way...')
     pkg_info = os.path.join(placeholder, file)
     if os.path.isdir(pkg_info):
         patched = _patch_egg_dir(pkg_info)
@@ -303,7 +302,7 @@
         patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
 
     if not patched:
-        log.warn('%s already patched.', pkg_info)
+        logging.warning('%s already patched.', pkg_info)
         return False
     # now let's move the files out of the way
     for element in ('setuptools', 'pkg_resources.py', 'site.py'):
@@ -311,7 +310,7 @@
         if os.path.exists(element):
             _rename_path(element)
         else:
-            log.warn('Could not find the %s element of the '
+            logging.warning('Could not find the %s element of the '
                      'Setuptools distribution', element)
     return True
 
@@ -319,28 +318,28 @@
 
 
 def _after_install(dist):
-    log.warn('After install bootstrap.')
+    logging.warning('After install bootstrap.')
     placeholder = dist.get_command_obj('install').install_purelib
     _create_fake_setuptools_pkg_info(placeholder)
 
 
 def _create_fake_setuptools_pkg_info(placeholder):
     if not placeholder or not os.path.exists(placeholder):
-        log.warn('Could not find the install location')
+        logging.warning('Could not find the install location')
         return
     pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
     setuptools_file = 'setuptools-%s-py%s.egg-info' % \
             (SETUPTOOLS_FAKED_VERSION, pyver)
     pkg_info = os.path.join(placeholder, setuptools_file)
     if os.path.exists(pkg_info):
-        log.warn('%s already exists', pkg_info)
+        logging.warning('%s already exists', pkg_info)
         return
 
-    log.warn('Creating %s', pkg_info)
+    logging.warning('Creating %s', pkg_info)
     try:
         f = open(pkg_info, 'w')
     except EnvironmentError:
-        log.warn("Don't have permissions to write %s, skipping", pkg_info)
+        logging.warning("Don't have permissions to write %s, skipping", pkg_info)
         return
     try:
         f.write(SETUPTOOLS_PKG_INFO)
@@ -348,7 +347,7 @@
         f.close()
 
     pth_file = os.path.join(placeholder, 'setuptools.pth')
-    log.warn('Creating %s', pth_file)
+    logging.warning('Creating %s', pth_file)
     f = open(pth_file, 'w')
     try:
         f.write(os.path.join(os.curdir, setuptools_file))
@@ -365,7 +364,7 @@
     pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
     if os.path.exists(pkg_info):
         if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
-            log.warn('%s already patched.', pkg_info)
+            logging.warning('%s already patched.', pkg_info)
             return False
     _rename_path(path)
     os.mkdir(path)
@@ -382,7 +381,7 @@
 
 
 def _before_install():
-    log.warn('Before install bootstrap.')
+    logging.warning('Before install bootstrap.')
     _fake_setuptools()
 
 
@@ -405,12 +404,12 @@
 
 
 def _fake_setuptools():
-    log.warn('Scanning installed packages')
+    logging.warning('Scanning installed packages')
     try:
         import pkg_resources
     except ImportError:
         # we're cool
-        log.warn('Setuptools or Distribute does not seem to be installed.')
+        logging.warning('Setuptools or Distribute does not seem to be installed.')
         return
     ws = pkg_resources.working_set
     try:
@@ -424,43 +423,43 @@
         )
 
     if setuptools_dist is None:
-        log.warn('No setuptools distribution found')
+        logging.warning('No setuptools distribution found')
         return
     # detecting if it was already faked
     setuptools_location = setuptools_dist.location
-    log.warn('Setuptools installation detected at %s', setuptools_location)
+    logging.warning('Setuptools installation detected at %s', setuptools_location)
 
     # if --root or --preix was provided, and if
     # setuptools is not located in them, we don't patch it
     if not _under_prefix(setuptools_location):
-        log.warn('Not patching, --root or --prefix is installing Distribute'
+        logging.warning('Not patching, --root or --prefix is installing Distribute'
                  ' in another location')
         return
 
     # let's see if its an egg
     if not setuptools_location.endswith('.egg'):
-        log.warn('Non-egg installation')
+        logging.warning('Non-egg installation')
         res = _remove_flat_installation(setuptools_location)
         if not res:
             return
     else:
-        log.warn('Egg installation')
+        logging.warning('Egg installation')
         pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
         if (os.path.exists(pkg_info) and
             _same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
-            log.warn('Already patched.')
+            logging.warning('Already patched.')
             return
-        log.warn('Patching...')
+        logging.warning('Patching...')
         # let's create a fake egg replacing setuptools one
         res = _patch_egg_dir(setuptools_location)
         if not res:
             return
-    log.warn('Patching complete.')
+    logging.warning('Patching complete.')
     _relaunch()
 
 
 def _relaunch():
-    log.warn('Relaunching...')
+    logging.warning('Relaunching...')
     # we have to relaunch the process
     # pip marker to avoid a relaunch bug
     _cmd1 = ['-c', 'install', '--single-version-externally-managed']
@@ -525,7 +524,7 @@
     install_args = []
     if options.user_install:
         if sys.version_info < (2, 6):
-            log.warn("--user requires Python 2.6 or later")
+            logging.warning("--user requires Python 2.6 or later")
             raise SystemExit(1)
         install_args.append('--user')
     return install_args