File: improve-compilation-system.patch

package info (click to toggle)
pydevd 3.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,892 kB
  • sloc: python: 77,580; cpp: 1,873; sh: 374; makefile: 50; ansic: 4
file content (261 lines) | stat: -rw-r--r-- 10,626 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
From: Julian Gilbey <jdg@debian.org>
Date: Tue, 28 Oct 2025 12:16:57 -0700
Subject: Use buildflags and only build one attach_linux binary

Forwarded: not-needed
Last-Update: 2024-06-30

 Original patch: William Grzybowski <william@grzy.org>
 The original code tries to build both 32-bit and 64-bit versions.
 This patched version only builds one copy of the library for the
 build architecture.
---
 .../add_code_to_python_process.py                  | 109 +--------------------
 pydevd_tracing.py                                  |  92 ++---------------
 2 files changed, 10 insertions(+), 191 deletions(-)

diff --git a/pydevd_attach_to_process/add_code_to_python_process.py b/pydevd_attach_to_process/add_code_to_python_process.py
index 8f5372c..c0bdc65 100644
--- a/pydevd_attach_to_process/add_code_to_python_process.py
+++ b/pydevd_attach_to_process/add_code_to_python_process.py
@@ -76,7 +76,6 @@ import subprocess
 import sys
 import time
 from contextlib import contextmanager
-import platform
 import traceback
 
 try:
@@ -141,114 +140,14 @@ def get_target_filename(is_target_process_64=None, prefix=None, extension=None):
     # and not from the debugger).
     libdir = os.path.dirname(os.path.abspath(__file__))
 
-    if is_target_process_64 is None:
-        if IS_WINDOWS:
-            # i.e.: On windows the target process could have a different bitness (32bit is emulated on 64bit).
-            raise AssertionError("On windows it's expected that the target bitness is specified.")
-
-        # For other platforms, just use the the same bitness of the process we're running in.
-        is_target_process_64 = is_python_64bit()
-
-    arch = ""
-    if IS_WINDOWS:
-        # prefer not using platform.machine() when possible (it's a bit heavyweight as it may
-        # spawn a subprocess).
-        arch = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get("PROCESSOR_ARCHITECTURE", ""))
-
-    if not arch:
-        arch = platform.machine()
-        if not arch:
-            print("platform.machine() did not return valid value.")  # This shouldn't happen...
-            return None
-
-    if IS_WINDOWS:
-        if not extension:
-            extension = ".dll"
-        suffix_64 = "amd64"
-        suffix_32 = "x86"
-
-    elif IS_LINUX:
-        if not extension:
-            extension = ".so"
-        suffix_64 = "amd64"
-        suffix_32 = "x86"
-
-    elif IS_MAC:
-        if not extension:
-            extension = ".dylib"
-        suffix_64 = "x86_64"
-        suffix_32 = "x86"
+    # This is a very simplified version for Debian builds
 
-    else:
+    if not IS_LINUX:
         print("Unable to attach to process in platform: %s", sys.platform)
         return None
 
-    if arch.lower() not in ("arm64", "amd64", "x86", "x86_64", "i386", "x86"):
-        # We don't support this processor by default. Still, let's support the case where the
-        # user manually compiled it himself with some heuristics.
-        #
-        # Ideally the user would provide a library in the format: "attach_<arch>.<extension>"
-        # based on the way it's currently compiled -- see:
-        # - windows/compile_windows.bat
-        # - linux_and_mac/compile_linux.sh
-        # - linux_and_mac/compile_mac.sh
-
-        try:
-            found = [name for name in os.listdir(libdir) if name.startswith("attach_") and name.endswith(extension)]
-        except:
-            print("Error listing dir: %s" % (libdir,))
-            traceback.print_exc()
-            return None
-
-        if prefix:
-            expected_name = prefix + arch + extension
-            expected_name_linux = prefix + "linux_" + arch + extension
-        else:
-            # Default is looking for the attach_ / attach_linux
-            expected_name = "attach_" + arch + extension
-            expected_name_linux = "attach_linux_" + arch + extension
-
-        filename = None
-        if expected_name in found:  # Heuristic: user compiled with "attach_<arch>.<extension>"
-            filename = os.path.join(libdir, expected_name)
-
-        elif IS_LINUX and expected_name_linux in found:  # Heuristic: user compiled with "attach_linux_<arch>.<extension>"
-            filename = os.path.join(libdir, expected_name_linux)
-
-        elif len(found) == 1:  # Heuristic: user removed all libraries and just left his own lib.
-            filename = os.path.join(libdir, found[0])
-
-        else:  # Heuristic: there's one additional library which doesn't seem to be our own. Find the odd one.
-            filtered = [name for name in found if not name.endswith((suffix_64 + extension, suffix_32 + extension))]
-            if len(filtered) == 1:  # If more than one is available we can't be sure...
-                filename = os.path.join(libdir, found[0])
-
-        if filename is None:
-            print("Unable to attach to process in arch: %s (did not find %s in %s)." % (arch, expected_name, libdir))
-            return None
-
-        print("Using %s in arch: %s." % (filename, arch))
-
-    else:
-        if is_target_process_64:
-            suffix = suffix_64
-        else:
-            suffix = suffix_32
-
-        if not prefix:
-            # Default is looking for the attach_ / attach_linux
-            if IS_WINDOWS:  # just the extension changes
-                prefix = "attach_"
-            elif IS_MAC:
-                prefix = "attach"
-                suffix = ""
-            elif IS_LINUX:
-                prefix = "attach_linux_"  # historically it has a different name
-            else:
-                print("Unable to attach to process in platform: %s" % (sys.platform,))
-                return None
-
-        filename = os.path.join(libdir, "%s%s%s" % (prefix, suffix, extension))
+    libname = "attach.so"
+    filename = os.path.join(libdir, libname)
 
     if not os.path.exists(filename):
         print("Expected: %s to exist." % (filename,))
diff --git a/pydevd_tracing.py b/pydevd_tracing.py
index a84ea1d..f3c4039 100644
--- a/pydevd_tracing.py
+++ b/pydevd_tracing.py
@@ -14,7 +14,6 @@ from _pydevd_bundle.pydevd_constants import (
 from _pydev_bundle._pydev_saved_modules import thread, threading
 from _pydev_bundle import pydev_log, pydev_monkey
 import os.path
-import platform
 import ctypes
 from io import StringIO
 import sys
@@ -170,95 +169,16 @@ def get_python_helper_lib_filename():
     if not os.path.exists(libdir):
         pydev_log.critical("Expected the directory: %s to exist!", libdir)
 
-    arch = ""
-    if IS_WINDOWS:
-        # prefer not using platform.machine() when possible (it's a bit heavyweight as it may
-        # spawn a subprocess).
-        arch = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get("PROCESSOR_ARCHITECTURE", ""))
+    # This is a very simplified version for Debian builds
 
-    if not arch:
-        arch = platform.machine()
-        if not arch:
-            pydev_log.info("platform.machine() did not return valid value.")  # This shouldn't happen...
-            return None
-
-    if IS_WINDOWS:
-        extension = ".dll"
-        suffix_64 = "amd64"
-        suffix_32 = "x86"
-
-    elif IS_LINUX:
-        extension = ".so"
-        suffix_64 = "amd64"
-        suffix_32 = "x86"
-
-    elif IS_MAC:
-        extension = ".dylib"
-        suffix_64 = "x86_64"
-        suffix_32 = "x86"
-
-    else:
-        pydev_log.info("Unable to set trace to all threads in platform: %s", sys.platform)
+    if not IS_LINUX:
+        print("Unable to set trace to all threads in platform: %s", sys.platform)
         return None
 
-    if arch.lower() not in ("arm64", "amd64", "x86", "x86_64", "i386", "x86"):
-        # We don't support this processor by default. Still, let's support the case where the
-        # user manually compiled it himself with some heuristics.
-        #
-        # Ideally the user would provide a library in the format: "attach_<arch>.<extension>"
-        # based on the way it's currently compiled -- see:
-        # - windows/compile_windows.bat
-        # - linux_and_mac/compile_linux.sh
-        # - linux_and_mac/compile_mac.sh
-
-        try:
-            found = [name for name in os.listdir(libdir) if name.startswith("attach_") and name.endswith(extension)]
-        except:
-            if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1:
-                # There is no need to show this unless debug tracing is enabled.
-                pydev_log.exception("Error listing dir: %s", libdir)
-            return None
-
-        expected_name = "attach_" + arch + extension
-        expected_name_linux = "attach_linux_" + arch + extension
-
-        filename = None
-        if expected_name in found:  # Heuristic: user compiled with "attach_<arch>.<extension>"
-            filename = os.path.join(libdir, expected_name)
-
-        elif IS_LINUX and expected_name_linux in found:  # Heuristic: user compiled with "attach_linux_<arch>.<extension>"
-            filename = os.path.join(libdir, expected_name_linux)
-
-        elif len(found) == 1:  # Heuristic: user removed all libraries and just left his own lib.
-            filename = os.path.join(libdir, found[0])
-
-        else:  # Heuristic: there's one additional library which doesn't seem to be our own. Find the odd one.
-            filtered = [name for name in found if not name.endswith((suffix_64 + extension, suffix_32 + extension))]
-            if len(filtered) == 1:  # If more than one is available we can't be sure...
-                filename = os.path.join(libdir, found[0])
-
-        if filename is None:
-            pydev_log.info("Unable to set trace to all threads in arch: %s (did not find a %s lib in %s).", arch, expected_name, libdir)
-            return None
-
-        pydev_log.info("Using %s lib in arch: %s.", filename, arch)
-
-    else:
-        # Happy path for which we have pre-compiled binaries.
-        if IS_64BIT_PROCESS:
-            suffix = suffix_64
-        else:
-            suffix = suffix_32
-
-        if IS_WINDOWS or IS_MAC:  # just the extension changes
-            prefix = "attach_"
-        elif IS_LINUX:  #
-            prefix = "attach_linux_"  # historically it has a different name
-        else:
-            pydev_log.info("Unable to set trace to all threads in platform: %s", sys.platform)
-            return None
+    libname = "attach.so"
+    filename = os.path.join(libdir, libname)
 
-        filename = os.path.join(libdir, "%s%s%s" % (prefix, suffix, extension))
+    pydev_log.info("Using %s lib.", filename)
 
     if not os.path.exists(filename):
         pydev_log.critical("Expected: %s to exist.", filename)