diff options
| author | Efraim Flashner <efraim@flashner.co.il> | 2026-04-13 16:39:18 +0300 |
|---|---|---|
| committer | Efraim Flashner <efraim@flashner.co.il> | 2026-04-13 17:36:13 +0300 |
| commit | cf94cd3e4e81d91af5bed34c33aa0046223b7a0c (patch) | |
| tree | 7f1483eba5b97aca986905083b73a3fc31df7f18 /gnu | |
| parent | f6365c6b3e5736a3a1665e25e4156133b9301698 (diff) | |
gnu: bam: Build with python3.
* gnu/packages/build-tools.scm (bam)[source]: Add patch.
[native-inputs]: Remove python-2; add python-minimal-wrapper.
* gnu/packages/patches/bam-python3-compat.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
Change-Id: Iec960101e148b7b71caf737cccdb5b762477a545
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/build-tools.scm | 5 | ||||
| -rw-r--r-- | gnu/packages/patches/bam-python3-compat.patch | 291 |
3 files changed, 295 insertions, 2 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 027451fc9ef..6b19ee1d929 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1039,6 +1039,7 @@ dist_patch_DATA = \ | |||
| 1039 | %D%/packages/patches/azr3.patch \ | 1039 | %D%/packages/patches/azr3.patch \ |
| 1040 | %D%/packages/patches/azr3-remove-lash.patch \ | 1040 | %D%/packages/patches/azr3-remove-lash.patch \ |
| 1041 | %D%/packages/patches/barony-fix-textures.patch \ | 1041 | %D%/packages/patches/barony-fix-textures.patch \ |
| 1042 | %D%/packages/patches/bam-python3-compat.patch \ | ||
| 1042 | %D%/packages/patches/bash-completion-directories.patch \ | 1043 | %D%/packages/patches/bash-completion-directories.patch \ |
| 1043 | %D%/packages/patches/bash-linux-pgrp-pipe.patch \ | 1044 | %D%/packages/patches/bash-linux-pgrp-pipe.patch \ |
| 1044 | %D%/packages/patches/basis-universal-unbundle-libs.patch \ | 1045 | %D%/packages/patches/basis-universal-unbundle-libs.patch \ |
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm index 813760f8455..5e401dbd846 100644 --- a/gnu/packages/build-tools.scm +++ b/gnu/packages/build-tools.scm | |||
| @@ -196,7 +196,8 @@ according to the system capabilities and the user-selected options.") | |||
| 196 | (file-name (git-file-name name version)) | 196 | (file-name (git-file-name name version)) |
| 197 | (sha256 | 197 | (sha256 |
| 198 | (base32 | 198 | (base32 |
| 199 | "13br735ig7lygvzyfd15fc2rdygrqm503j6xj5xkrl1r7w2wipq6")))) | 199 | "13br735ig7lygvzyfd15fc2rdygrqm503j6xj5xkrl1r7w2wipq6")) |
| 200 | (patches (search-patches "bam-python3-compat.patch")))) | ||
| 200 | (build-system gnu-build-system) | 201 | (build-system gnu-build-system) |
| 201 | (arguments | 202 | (arguments |
| 202 | `(#:make-flags `(,(string-append "CC=" ,(cc-for-target)) | 203 | `(#:make-flags `(,(string-append "CC=" ,(cc-for-target)) |
| @@ -207,7 +208,7 @@ according to the system capabilities and the user-selected options.") | |||
| 207 | (modify-phases %standard-phases | 208 | (modify-phases %standard-phases |
| 208 | (delete 'configure)))) | 209 | (delete 'configure)))) |
| 209 | (native-inputs | 210 | (native-inputs |
| 210 | `(("python" ,python-2))) | 211 | (list python-minimal-wrapper)) |
| 211 | (inputs | 212 | (inputs |
| 212 | (list lua)) | 213 | (list lua)) |
| 213 | (home-page "https://matricks.github.io/bam/") | 214 | (home-page "https://matricks.github.io/bam/") |
diff --git a/gnu/packages/patches/bam-python3-compat.patch b/gnu/packages/patches/bam-python3-compat.patch new file mode 100644 index 00000000000..81d56a3e2ff --- /dev/null +++ b/gnu/packages/patches/bam-python3-compat.patch | |||
| @@ -0,0 +1,291 @@ | |||
| 1 | This patch is taken from the upstream repository | ||
| 2 | |||
| 3 | From b937572d157e660af98e224523ffb3fe5810ed2c Mon Sep 17 00:00:00 2001 | ||
| 4 | Message-ID: <b937572d157e660af98e224523ffb3fe5810ed2c.1776087342.git.efraim@flashner.co.il> | ||
| 5 | From: Felix Geyer <debfx@fobos.de> | ||
| 6 | Date: Fri, 30 Aug 2019 19:08:35 +0200 | ||
| 7 | Subject: [PATCH] Port scripts to Python 3 | ||
| 8 | |||
| 9 | Compatibility with Python 2 is preserved. | ||
| 10 | --- | ||
| 11 | scripts/gendocs.py | 2 +- | ||
| 12 | scripts/test.py | 67 +++++++++++++++++++++++----------------------- | ||
| 13 | scripts/tinydoc.py | 23 ++++++++-------- | ||
| 14 | 3 files changed, 47 insertions(+), 45 deletions(-) | ||
| 15 | |||
| 16 | diff --git a/scripts/gendocs.py b/scripts/gendocs.py | ||
| 17 | index c9f206e..ba872c4 100644 | ||
| 18 | --- a/scripts/gendocs.py | ||
| 19 | +++ b/scripts/gendocs.py | ||
| 20 | @@ -29,6 +29,6 @@ root.nodes += [ParseTextFile(Node("License"), "license.txt", True)] | ||
| 21 | |||
| 22 | # render files | ||
| 23 | for o in outputs: | ||
| 24 | - o.file = file(o.output_name(), "w") | ||
| 25 | + o.file = open(o.output_name(), "w") | ||
| 26 | o.render(root) | ||
| 27 | o.file.close() | ||
| 28 | diff --git a/scripts/test.py b/scripts/test.py | ||
| 29 | index accc26c..bbc9c7d 100755 | ||
| 30 | --- a/scripts/test.py | ||
| 31 | +++ b/scripts/test.py | ||
| 32 | @@ -1,5 +1,6 @@ | ||
| 33 | #!/usr/bin/env python | ||
| 34 | |||
| 35 | +from __future__ import print_function | ||
| 36 | import os, sys, shutil, subprocess | ||
| 37 | |||
| 38 | extra_bam_flags = "" | ||
| 39 | @@ -36,8 +37,8 @@ def copytree(src, dst): | ||
| 40 | copytree(srcname, dstname) | ||
| 41 | else: | ||
| 42 | shutil.copy2(srcname, dstname) | ||
| 43 | - except (IOError, os.error), why: | ||
| 44 | - print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) | ||
| 45 | + except (IOError, os.error) as why: | ||
| 46 | + print("Can't copy '%s' to '%s': %s" % (srcname, dstname, str(why))) | ||
| 47 | |||
| 48 | |||
| 49 | def run_bam(testname, flags): | ||
| 50 | @@ -45,7 +46,7 @@ def run_bam(testname, flags): | ||
| 51 | olddir = os.getcwd() | ||
| 52 | os.chdir(output_path+"/"+testname) | ||
| 53 | |||
| 54 | - p = subprocess.Popen(bam+" "+flags, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) | ||
| 55 | + p = subprocess.Popen(bam+" "+flags, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT, universal_newlines=True) | ||
| 56 | report = p.stdout.readlines() | ||
| 57 | p.wait() | ||
| 58 | ret = p.returncode | ||
| 59 | @@ -64,8 +65,8 @@ def test(name, moreflags="", should_fail=0): | ||
| 60 | os.chdir(output_path+"/"+name) | ||
| 61 | cmdline = bam+" -t -v "+extra_bam_flags+" " + moreflags | ||
| 62 | |||
| 63 | - print name + ":", | ||
| 64 | - p = subprocess.Popen(cmdline, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) | ||
| 65 | + print(name + ":", end=" ") | ||
| 66 | + p = subprocess.Popen(cmdline, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT, universal_newlines=True) | ||
| 67 | report = p.stdout.readlines() | ||
| 68 | p.wait() | ||
| 69 | ret = p.returncode | ||
| 70 | @@ -73,50 +74,50 @@ def test(name, moreflags="", should_fail=0): | ||
| 71 | os.chdir(olddir) | ||
| 72 | |||
| 73 | if (should_fail and not ret) or (not should_fail and ret): | ||
| 74 | - print " FAILED!" | ||
| 75 | + print(" FAILED!") | ||
| 76 | for l in report: | ||
| 77 | - print "\t", l, | ||
| 78 | + print("\t", l, end=" ") | ||
| 79 | failed_tests += [name + "(returned %d)" % ret] | ||
| 80 | else: | ||
| 81 | - print " ok" | ||
| 82 | + print(" ok") | ||
| 83 | |||
| 84 | def difftest(name, flags1, flags2): | ||
| 85 | global failed_tests | ||
| 86 | if len(tests) and not name in tests: | ||
| 87 | return | ||
| 88 | testname = "difftest: %s '%s' vs '%s': "%(name, flags1, flags2) | ||
| 89 | - print testname, | ||
| 90 | + print(testname, end=" ") | ||
| 91 | ret1, report1 = run_bam(name, flags1) | ||
| 92 | ret2, report2 = run_bam(name, flags2) | ||
| 93 | |||
| 94 | if ret1: | ||
| 95 | - print "FAILED! '%s' returned %d" %(flags1, ret1) | ||
| 96 | + print("FAILED! '%s' returned %d" %(flags1, ret1)) | ||
| 97 | failed_tests += [testname] | ||
| 98 | return | ||
| 99 | |||
| 100 | if ret2: | ||
| 101 | - print "FAILED! '%s' returned %d" %(flags2, ret2) | ||
| 102 | + print("FAILED! '%s' returned %d" %(flags2, ret2)) | ||
| 103 | failed_tests += [testname] | ||
| 104 | return | ||
| 105 | |||
| 106 | if len(report1) != len(report2): | ||
| 107 | - print "FAILED! %d lines vs %d lines" % (len(report1), len(report2)) | ||
| 108 | + print("FAILED! %d lines vs %d lines" % (len(report1), len(report2))) | ||
| 109 | failed_tests += [testname] | ||
| 110 | return | ||
| 111 | |||
| 112 | failed = 0 | ||
| 113 | - for i in xrange(0, len(report1)): | ||
| 114 | + for i in range(0, len(report1)): | ||
| 115 | if report1[i] != report2[i]: | ||
| 116 | if not failed: | ||
| 117 | - print "FAILED!" | ||
| 118 | - print "1:", report1[i].strip() | ||
| 119 | - print "2:", report2[i].strip() | ||
| 120 | + print("FAILED!") | ||
| 121 | + print("1:", report1[i].strip()) | ||
| 122 | + print("2:", report2[i].strip()) | ||
| 123 | failed += 1 | ||
| 124 | |||
| 125 | if failed: | ||
| 126 | failed_tests += [testname] | ||
| 127 | else: | ||
| 128 | - print "ok" | ||
| 129 | + print("ok") | ||
| 130 | |||
| 131 | def unittests(): | ||
| 132 | global failed_tests | ||
| 133 | @@ -129,7 +130,7 @@ def unittests(): | ||
| 134 | |||
| 135 | tests = [] | ||
| 136 | state = 0 | ||
| 137 | - for line in file('src/base.lua'): | ||
| 138 | + for line in open('src/base.lua'): | ||
| 139 | if state == 0: | ||
| 140 | if "@UNITTESTS" in line: | ||
| 141 | state = 1 | ||
| 142 | @@ -157,16 +158,16 @@ def unittests(): | ||
| 143 | os.chdir(output_path+"/unit") | ||
| 144 | |||
| 145 | for test in tests: | ||
| 146 | - f = file("bam.lua", "w") | ||
| 147 | + f = open("bam.lua", "w") | ||
| 148 | if test.catch != None: | ||
| 149 | - print >>f, "print(\"CATCH:\", %s)"%(test.line) | ||
| 150 | + print("print(\"CATCH:\", %s)"%(test.line), file=f) | ||
| 151 | else: | ||
| 152 | - print >>f, test.line | ||
| 153 | - print >>f, 'DefaultTarget(PseudoTarget("Test"))' | ||
| 154 | + print(test.line, file=f) | ||
| 155 | + print('DefaultTarget(PseudoTarget("Test"))', file=f) | ||
| 156 | f.close() | ||
| 157 | |||
| 158 | - print "%s:"%(test.line), | ||
| 159 | - p = subprocess.Popen(bam + " --dry", stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) | ||
| 160 | + print("%s:"%(test.line), end=" ") | ||
| 161 | + p = subprocess.Popen(bam + " --dry", stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT, universal_newlines=True) | ||
| 162 | report = p.stdout.readlines() | ||
| 163 | p.wait() | ||
| 164 | ret = p.returncode | ||
| 165 | @@ -174,7 +175,7 @@ def unittests(): | ||
| 166 | failed = False | ||
| 167 | if ret != test.err: | ||
| 168 | failed = True | ||
| 169 | - print "FAILED! error %d != %d" % (test.err, ret) | ||
| 170 | + print("FAILED! error %d != %d" % (test.err, ret)) | ||
| 171 | |||
| 172 | if test.catch != None: | ||
| 173 | found = False | ||
| 174 | @@ -185,7 +186,7 @@ def unittests(): | ||
| 175 | if catched == test.catch: | ||
| 176 | found = True | ||
| 177 | else: | ||
| 178 | - print "FAILED! catch '%s' != '%s'" % (test.catch, catched) | ||
| 179 | + print("FAILED! catch '%s' != '%s'" % (test.catch, catched)) | ||
| 180 | |||
| 181 | if not found: | ||
| 182 | failed = True | ||
| 183 | @@ -198,16 +199,16 @@ def unittests(): | ||
| 184 | |||
| 185 | if not found: | ||
| 186 | failed = True | ||
| 187 | - print "FAILED! could not find '%s' in output" % (test.find) | ||
| 188 | + print("FAILED! could not find '%s' in output" % (test.find)) | ||
| 189 | if failed or verbose: | ||
| 190 | if failed: | ||
| 191 | failed_tests += [test.line] | ||
| 192 | else: | ||
| 193 | - print "", | ||
| 194 | + print("", end=" ") | ||
| 195 | for l in report: | ||
| 196 | - print "\t", l.rstrip() | ||
| 197 | + print("\t", l.rstrip()) | ||
| 198 | else: | ||
| 199 | - print "ok" | ||
| 200 | + print("ok") | ||
| 201 | |||
| 202 | |||
| 203 | os.chdir(olddir) | ||
| 204 | @@ -246,11 +247,11 @@ test("multipleoutput") | ||
| 205 | test("missingoutput", "", 1) | ||
| 206 | |||
| 207 | if len(failed_tests): | ||
| 208 | - print "FAILED TESTS:" | ||
| 209 | + print("FAILED TESTS:") | ||
| 210 | for t in failed_tests: | ||
| 211 | - print "\t"+t | ||
| 212 | + print("\t"+t) | ||
| 213 | sys.exit(1) | ||
| 214 | else: | ||
| 215 | - print "ALL TESTS PASSED!" | ||
| 216 | + print("ALL TESTS PASSED!") | ||
| 217 | sys.exit(0) | ||
| 218 | |||
| 219 | diff --git a/scripts/tinydoc.py b/scripts/tinydoc.py | ||
| 220 | index 536a74f..6557cf8 100644 | ||
| 221 | --- a/scripts/tinydoc.py | ||
| 222 | +++ b/scripts/tinydoc.py | ||
| 223 | @@ -1,4 +1,5 @@ | ||
| 224 | |||
| 225 | +from __future__ import print_function | ||
| 226 | import re, time | ||
| 227 | |||
| 228 | class Node: | ||
| 229 | @@ -47,20 +48,20 @@ class Output: | ||
| 230 | |||
| 231 | def render_node_index(self, cur): | ||
| 232 | if len(cur.index): | ||
| 233 | - print >>self.file, self.index_node_begin(cur) | ||
| 234 | + print(self.index_node_begin(cur), file=self.file) | ||
| 235 | for node in cur.nodes: | ||
| 236 | self.render_node_index(node) | ||
| 237 | if len(cur.index): | ||
| 238 | - print >>self.file, self.index_node_end(cur) | ||
| 239 | + print(self.index_node_end(cur), file=self.file) | ||
| 240 | def render_node(self, cur): | ||
| 241 | if len(cur.index): | ||
| 242 | - print >>self.file, self.format_header(cur) | ||
| 243 | - print >>self.file, self.format_body(cur) | ||
| 244 | + print(self.format_header(cur), file=self.file) | ||
| 245 | + print(self.format_body(cur), file=self.file) | ||
| 246 | for node in cur.nodes: | ||
| 247 | self.render_node(node) | ||
| 248 | |||
| 249 | def index_nodes(self, cur, index=""): | ||
| 250 | - for i in xrange(0, len(cur.nodes)): | ||
| 251 | + for i in range(0, len(cur.nodes)): | ||
| 252 | if len(index): | ||
| 253 | cur.nodes[i].index = index + "." + str(i+1) | ||
| 254 | else: | ||
| 255 | @@ -73,14 +74,14 @@ class Output: | ||
| 256 | |||
| 257 | def render(self, rootnode): | ||
| 258 | self.index_nodes(rootnode) | ||
| 259 | - print >>self.file, self.render_begin() | ||
| 260 | + print(self.render_begin(), file=self.file) | ||
| 261 | |||
| 262 | - print >>self.file, self.index_begin() | ||
| 263 | + print(self.index_begin(), file=self.file) | ||
| 264 | self.render_node_index(rootnode) | ||
| 265 | - print >>self.file, self.index_end() | ||
| 266 | + print(self.index_end(), file=self.file) | ||
| 267 | |||
| 268 | self.render_node(rootnode) | ||
| 269 | - print >>self.file, self.render_end() | ||
| 270 | + print(self.render_end(), file=self.file) | ||
| 271 | |||
| 272 | class HTMLOutput(Output): | ||
| 273 | def render_begin(self): | ||
| 274 | @@ -225,7 +226,7 @@ class HTMLOutput(Output): | ||
| 275 | |||
| 276 | def ParseTextFile(rootnode, filename, addbr=False): | ||
| 277 | group = rootnode | ||
| 278 | - for line in file(filename): | ||
| 279 | + for line in open(filename): | ||
| 280 | if group_tag in line: | ||
| 281 | group_name = line.split(group_tag)[-1].split(end_tag)[0].strip() | ||
| 282 | group = Node(group_name) | ||
| 283 | @@ -244,7 +245,7 @@ def ParseFile(rootnode, filename): | ||
| 284 | # 2 = outputting function decl | ||
| 285 | state = 0 | ||
| 286 | group = rootnode | ||
| 287 | - for line in file(filename): | ||
| 288 | + for line in open(filename): | ||
| 289 | if state == 0: | ||
| 290 | if group_tag in line: | ||
| 291 | group_name = line.split(group_tag)[-1].split(end_tag)[0].strip() | ||
