projects/guix·blob python-team · refs

293 lines · 11.0 KiB

1From e66f3adc4a941341fbfceb6e078d24c52e8e7c93 Mon Sep 17 00:00:00 2001
2From: JP Cimalando <[email protected]>
3Date: Thu, 24 Oct 2019 17:55:57 +0200
4Subject: [PATCH] Make the scons build compatible with Python 3
5
6---
7 SConstruct | 86 +++++++++++++++++++++++++++---------------------------
8 1 file changed, 43 insertions(+), 43 deletions(-)
9
10diff --git a/SConstruct b/SConstruct
11index a46f14b0..d1a6506a 100644
12--- a/SConstruct
13+++ b/SConstruct
14@@ -106,14 +106,14 @@ def main_Aria_func():
15 elif os.uname()[0] == 'Darwin':
16 which_os = "macosx"
17 else:
18- print "!! Unknown operating system '" + os.uname()[0] + "', defaulting to Unix"
19+ print("!! Unknown operating system '" + os.uname()[0] + "', defaulting to Unix")
20 which_os = "unix"
21
22 if not which_os in ["netbsd", "linux", "macosx", "unix", "windows"]:
23- print "!! Unknown operating system '" + which_os + "', please specify 'platform=[linux/macosx/unix/windows/netbsd]'"
24+ print("!! Unknown operating system '" + which_os + "', please specify 'platform=[linux/macosx/unix/windows/netbsd]'")
25 sys.exit(0)
26
27- print">> Operating system : " + which_os
28+ print(">> Operating system : " + which_os)
29
30 # check what to do
31 if 'uninstall' in COMMAND_LINE_TARGETS:
32@@ -121,7 +121,7 @@ def main_Aria_func():
33 if which_os in ["linux", "unix", "netbsd"]:
34 uninstall_Aria_unix()
35 else:
36- print "!! Unknown operation or system (uninstall is not valid on your system)"
37+ print("!! Unknown operation or system (uninstall is not valid on your system)")
38 sys.exit(0)
39 elif 'install' in COMMAND_LINE_TARGETS:
40 # install
41@@ -130,7 +130,7 @@ def main_Aria_func():
42 elif which_os == "macosx":
43 install_Aria_mac()
44 else:
45- print "!! Unknown operation or system (install is not valid on your system)"
46+ print("!! Unknown operation or system (install is not valid on your system)")
47 sys.exit(0)
48 else:
49 # compile
50@@ -147,10 +147,10 @@ def install_Aria_mac():
51 sys_command("cp -r ./OSX/*.icns ./Aria\ Maestosa.app/Contents/Resources/.")
52 sys_command("touch ./Aria\ Maestosa.app")
53
54- print "*** Cleaning up..."
55+ print("*** Cleaning up...")
56 os.system("cd ./Aria\ Maestosa.app && find . -name \".svn\" -exec rm -rf '{}' \;")
57
58- print "*** Done"
59+ print("*** Done")
60 sys.exit(0)
61
62 # ---------------------------- Uninstall Linux -----------------------------
63@@ -161,10 +161,10 @@ def uninstall_Aria_unix():
64 prefix = ARGUMENTS.get('prefix', 0)
65
66 if prefix == 0:
67- print ">> No prefix specified, defaulting to /usr/local/"
68+ print(">> No prefix specified, defaulting to /usr/local/")
69 prefix = '/usr/local/'
70 else:
71- print ">> Prefix: " + prefix
72+ print(">> Prefix: " + prefix)
73
74 if prefix[-1] != "/":
75 prefix += "/"
76@@ -177,16 +177,16 @@ def uninstall_Aria_unix():
77 os.system("rm " + app_path)
78 os.system("rm " + locale_path + "*/LC_MESSAGES/aria_maestosa.mo")
79
80- print "\n*** Uninstall done"
81+ print("\n*** Uninstall done")
82 sys.exit(0)
83
84 # -- small helper func
85 # executes a command on the system shell and prints it to stdout
86 def sys_command(command):
87- print command
88+ print(command)
89 return_status = os.system(command)
90 if return_status != 0:
91- print "An error occured"
92+ print("An error occured")
93 sys.exit(0)
94
95 # ---------------------------- Compile -----------------------------
96@@ -204,16 +204,16 @@ def compile_Aria(which_os):
97 env['ENV']['PATH'] = os.environ.get('PATH')
98
99 if 'CXX' in os.environ:
100- print ">> Using compiler " + os.environ['CXX']
101+ print(">> Using compiler " + os.environ['CXX'])
102 env.Replace(CXX = os.environ['CXX'])
103
104 # check build style
105 build_type = ARGUMENTS.get('config', 'release')
106 if build_type != 'release' and build_type != 'debug':
107- print "!! Unknown build config " + build_type
108+ print("!! Unknown build config " + build_type)
109 sys.exit(0)
110
111- print ">> Build type : " + build_type
112+ print(">> Build type : " + build_type)
113
114 # check renderer
115 if which_os == "macosx":
116@@ -221,10 +221,10 @@ def compile_Aria(which_os):
117 else:
118 renderer = ARGUMENTS.get('renderer', 'wxwidgets')
119 if renderer != 'opengl' and renderer != 'wxwidgets':
120- print "!! Unknown renderer " + renderer
121+ print("!! Unknown renderer " + renderer)
122 sys.exit(0)
123
124- print ">> Renderer : " + renderer
125+ print(">> Renderer : " + renderer)
126 if renderer == 'opengl':
127 env.Append(CCFLAGS=['-DRENDERER_OPENGL'])
128 elif renderer == 'wxwidgets':
129@@ -233,16 +233,16 @@ def compile_Aria(which_os):
130 # Check architecture
131 compiler_arch = ARGUMENTS.get('compiler_arch', platform.architecture(env['CXX']))[0]
132 if compiler_arch != '32bit' and compiler_arch != '64bit':
133- print 'Invalid architecture : ', compiler_arch, '; assuming 32bit'
134+ print('Invalid architecture : ', compiler_arch, '; assuming 32bit')
135 compiler_arch = '32bit'
136
137- print ">> Architecture : " + compiler_arch
138+ print(">> Architecture : " + compiler_arch)
139
140 # add wxWidgets flags
141 # check if user defined his own WXCONFIG, else use defaults
142 WXCONFIG = ARGUMENTS.get('WXCONFIG', 'wx-config')
143 if which_os != 'windows':
144- print ">> wx-config : " + WXCONFIG
145+ print(">> wx-config : " + WXCONFIG)
146
147 if which_os == 'windows':
148
149@@ -262,12 +262,12 @@ def compile_Aria(which_os):
150 if renderer == "opengl":
151 winLdFlags = winLdFlags + ['-lopengl32','-lwxmsw312u_gl_gcc_custom','-lglu32']
152
153- print "Build flags :", winCppFlags
154- print "Link flags :", winLdFlags
155+ print("Build flags :", winCppFlags)
156+ print("Link flags :", winLdFlags)
157
158 try:
159 command = ["windres", "--include-dir="+wxHomePath+"\include", "--input", "win32\Aria.rc", "--output", "msvcr.o"]
160- print command
161+ print(command)
162 out = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
163 except:
164 sys.stderr.write("could not execute 'windres', is mingw installed?\n")
165@@ -278,8 +278,8 @@ def compile_Aria(which_os):
166 # Ugly hack : wx flags need to appear at the end of the command, but scons doesn't support that, so I need to hack their link command
167 env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS ' + (' -mwindows ' if build_type == 'release' else '') + ' '.join(winLdFlags)
168 else:
169- wxversion = subprocess.check_output([WXCONFIG,"--version"]).strip()
170- print ">> wxWidgets version : " + wxversion
171+ wxversion = subprocess.check_output([WXCONFIG,"--version"]).decode().strip()
172+ print(">> wxWidgets version : " + wxversion)
173 is_wx_3 = (wxversion[0] == '3' or (wxversion[0] == '2' and wxversion[2] == '9'))
174 if is_wx_3:
175 if renderer == "opengl":
176@@ -308,16 +308,16 @@ def compile_Aria(which_os):
177 env.Append(CCFLAGS=['-O2','-DNDEBUG=1'])
178
179 else:
180- print 'Unknown build type, cannot continue'
181+ print('Unknown build type, cannot continue')
182 sys.exit(0)
183
184 # init common header search paths
185 env.Append(CPPPATH = ['./Src','.','./libjdkmidi/include','./rtmidi'])
186
187- print " "
188+ print(" ")
189
190 # add common sources
191- print "*** Adding source files"
192+ print("*** Adding source files")
193
194 sources = []
195 for file in RecursiveGlob(".", "*.cpp"):
196@@ -341,7 +341,7 @@ def compile_Aria(which_os):
197 # OS X (QTKit, CoreAudio, audiotoolbox)
198 if which_os == "macosx":
199
200- print "*** Adding mac source files and libraries"
201+ print("*** Adding mac source files and libraries")
202 env.Append(CCFLAGS=['-D_MAC_QUICKTIME_COREAUDIO'])
203 sources = sources + ['Src/Midi/Players/Mac/QuickTimeExport.mm','Src/GUI/Machelper.mm']
204 env.Append(CPPPATH=['Src/Midi/Players/Mac'])
205@@ -365,7 +365,7 @@ def compile_Aria(which_os):
206 # NetBSD, FreeBSD (Alsa/tiMidity)
207 elif which_os == "netbsd":
208
209- print "*** Adding Alsa libraries and defines"
210+ print("*** Adding Alsa libraries and defines")
211
212 if renderer == 'opengl':
213 env.Append(CCFLAGS=['-DwxUSE_GLCANVAS=1'])
214@@ -389,7 +389,7 @@ def compile_Aria(which_os):
215 # linux (Alsa/tiMidity)
216 elif which_os == "linux":
217
218- print "*** Adding Alsa libraries and defines"
219+ print("*** Adding Alsa libraries and defines")
220
221 if renderer == 'opengl':
222 env.Append(CCFLAGS=['-DwxUSE_GLCANVAS=1'])
223@@ -415,7 +415,7 @@ def compile_Aria(which_os):
224 env.ParseConfig( 'pkg-config --libs glib-2.0' )
225
226 elif which_os == "unix":
227- print "*** Adding libraries and defines for Unix"
228+ print("*** Adding libraries and defines for Unix")
229
230 if renderer == 'opengl':
231 env.Append(CCFLAGS=['-DwxUSE_GLCANVAS=1'])
232@@ -436,7 +436,7 @@ def compile_Aria(which_os):
233
234 else:
235
236- print "\n\n/!\\ Platform ", which_os, " is unknown"
237+ print("\n\n/!\\ Platform ", which_os, " is unknown")
238 sys.exit(0)
239
240
241@@ -449,11 +449,11 @@ def compile_Aria(which_os):
242 # **************************************** COMPILE ********************************************
243 # *********************************************************************************************
244
245- print " "
246- print "====================="
247- print " Setup done "
248- print "====================="
249- print " "
250+ print(" ")
251+ print("=====================")
252+ print(" Setup done ")
253+ print("=====================")
254+ print(" ")
255
256 # compile to .o
257 object_list = env.Object(source = sources)
258@@ -471,14 +471,14 @@ def compile_Aria(which_os):
259 prefix = ARGUMENTS.get('prefix', 0)
260
261 if prefix == 0:
262- print ">> No prefix specified, defaulting to /usr/local/"
263+ print(">> No prefix specified, defaulting to /usr/local/")
264 prefix = '/usr/local/'
265 else:
266- print ">> Prefix : " + prefix
267+ print(">> Prefix : " + prefix)
268
269 # set umask so created directories have the correct permissions
270 try:
271- umask = os.umask(022)
272+ umask = os.umask(0o022)
273 except OSError: # ignore on systems that don't support umask
274 pass
275
276@@ -495,7 +495,7 @@ def compile_Aria(which_os):
277 env.Command( executable_target, executable,
278 [
279 Copy("$TARGET","$SOURCE"),
280- Chmod("$TARGET", 0775),
281+ Chmod("$TARGET", 0o0775),
282 ])
283
284
285@@ -513,7 +513,7 @@ def compile_Aria(which_os):
286 env.Command( target, source,
287 [
288 Copy("$TARGET","$SOURCE"),
289- Chmod("$TARGET", 0664),
290+ Chmod("$TARGET", 0o0664),
291 ])
292
293 # install .mo files