diff options
author | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-09-14 11:48:49 -0700 |
---|---|---|
committer | RJ Skerry-Ryan <rryan@mixxx.org> | 2018-09-14 11:48:49 -0700 |
commit | 73d02e58bcd55ac4e0c3ce6047b28057629ddd7e (patch) | |
tree | c876267b695a064c0a1a3d50afa95d7c712fc5f5 /build | |
parent | 033b6d76935c51cac62a535c945f2ba769f1bb01 (diff) |
SCons Python 3 support for macOS.
Diffstat (limited to 'build')
-rw-r--r-- | build/depends.py | 2 | ||||
-rw-r--r-- | build/osx/OSConsX.py | 32 | ||||
-rw-r--r-- | build/osx/otool.py | 21 |
3 files changed, 27 insertions, 28 deletions
diff --git a/build/depends.py b/build/depends.py index 9f3dcbd112..9f3e4917fb 100644 --- a/build/depends.py +++ b/build/depends.py @@ -597,7 +597,7 @@ class SoundTouch(Dependence): env.Append(CPPPATH=[self.SOUNDTOUCH_INTERNAL_PATH]) # Prevents circular import. - from features import Optimize + from .features import Optimize # If we do not want optimizations then disable them. optimize = (build.flags['optimize'] if 'optimize' in build.flags diff --git a/build/osx/OSConsX.py b/build/osx/OSConsX.py index 4434288d12..bf3584aa31 100644 --- a/build/osx/OSConsX.py +++ b/build/osx/OSConsX.py @@ -33,7 +33,7 @@ import otool def system(s): "wrap system() to give us feedback on what it's doing" "anything using this call should be fixed to use SCons's declarative style (once you figure that out, right nick?)" - print s, + print(s), sys.stdout.flush() #ignore line buffering.. result = os.system(s) print @@ -54,10 +54,10 @@ def InstallDir(target, source, env): #XXX this belongs not in this module #Mkdir(os.path.join(str(target), str(source))) #translate install(a/, b/) to install(a/b/, [files in b]) contents = Glob(os.path.join(str(source), "*")) #XXX there's probably a cleaner way that SCons has to do this - #print "contents:",contents + #print("contents:", contents) files = filter(lambda f: isinstance(f, SCons.Node.FS.File), contents) folders = filter(lambda f: isinstance(f, SCons.Node.FS.Dir), contents) - #print map(str, folders) + #print(map(str, folders)) name = os.path.basename(str(source)) #install the files local to this @@ -91,7 +91,7 @@ def build_dmg(target, source, env): #aah there must be a more SCons-ey (i.e. declarative) way to do all this; the trouble with doing os.mkdir(dmg) for f in source: - print "Copying",f + print("Copying", f) a, b = str(f), os.path.join(dmg, os.path.basename(str(f.path))) if isinstance(f, SCons.Node.FS.Dir): #XXX there's a lot of cases that could throw this off, particularly if you try to pass in subdirs copier = shutil.copytree @@ -102,8 +102,8 @@ def build_dmg(target, source, env): try: copier(a, b) - except Exception, e: - print "ERRRR", e + except Exception as e: + print("ERRRR", e) raise Exception("Error copying %s: " % (a,), e) # Symlink Applications to /Applications @@ -259,9 +259,9 @@ def build_app(target, source, env): embedded_p = os.path.join(str(plugins), subdir, os.path.basename(str(p))) plugins_l.append( (p, embedded_p) ) - print "Scanning plugins for new dependencies:" + print("Scanning plugins for new dependencies:") for p, ep in plugins_l: - print "Scanning plugin", p + print("Scanning plugin", p) for ref, path in otool.embed_dependencies(p, LOCAL=otool_local_paths, SYSTEM=otool_system_paths): if ref not in locals: locals[ref] = path, embed_lib(path) @@ -272,7 +272,7 @@ def build_app(target, source, env): #better yet, make a Frameworks type that you say Framework("QtCore") and then can use that as a dependency - print "Installing main binary:" + print("Installing main binary:") Execute(Copy(installed_bin, binary)) #e.g. this SHOULD be an env.Install() call, but if scons decides to run build_app before that env.Install then build_app fails and brings the rest of the build with it, of course for ref in otool.dependencies(str(installed_bin)): if ref in locals: @@ -282,24 +282,24 @@ def build_app(target, source, env): system("strip '%s'" % installed_bin) - print "Installing embedded libs:" + print("Installing embedded libs:") for ref, (abs, embedded) in locals.items(): real_abs = os.path.realpath(abs) - print "installing", real_abs, "to", embedded + print("installing", real_abs, "to", embedded) # NOTE(rryan): abs can be a symlink. we want to copy the binary it is # pointing to. os.path.realpath does this for us. Execute(Copy(embedded, real_abs)) if not os.access(embedded, os.W_OK): - print "Adding write permissions to %s" % embedded_p + print("Adding write permissions to %s" % embedded_p) mode = os.stat(embedded).st_mode os.chmod(embedded, mode | stat.S_IWUSR) patch_lib(embedded) - print "Installing plugins:" + print("Installing plugins:") for p, embedded_p in plugins_l: real_p = os.path.realpath(p) - print "installing", real_p, "to", embedded_p + print("installing", real_p, "to", embedded_p) # NOTE(rryan): p can be a symlink. we want to copy the binary it is # pointing to. os.path.realpath does this for us. Execute(Copy(embedded_p, real_p)) #:/ @@ -448,7 +448,7 @@ def emit_app(target, source, env): App = Builder(action = build_app, emitter = emit_app) def codesign_path(identity, keychain, entitlements, path): - print "Codesigning: ", path + print("Codesigning: ", path) command = "codesign -f -s '%s'%s%s %s" % ( identity, ' --keychain %s' % keychain if keychain else '', @@ -479,7 +479,7 @@ def do_codesign(target, source, env): entitlements = env.get('CODESIGN_ENTITLEMENTS', None) if application_identity is not None: if keychain and keychain_password is not None: - print "Unlocking keychain:" + print("Unlocking keychain:") if system("security unlock-keychain -p '%s' %s" % (keychain_password, keychain)) != 0: raise Exception('Could not unlock keychain.') diff --git a/build/osx/otool.py b/build/osx/otool.py index f1d292533d..c350c79f7c 100644 --- a/build/osx/otool.py +++ b/build/osx/otool.py @@ -40,10 +40,10 @@ import sys,os def system(s): "wrap system() to give us feedback on what it's doing" "anything using this call should be fixed to use SCons's declarative style (once you figure that out, right nick?)" - print s, + print(s), sys.stdout.flush() #ignore line buffering.. result = os.system(s) - print + print() return result @@ -52,14 +52,13 @@ SYSTEM_FRAMEWORKS = ["/System/Library/Frameworks"] SYSTEM_LIBPATH = ["/usr/lib"] #anything else? #paths to libs that we should copy in LOCAL_FRAMEWORKS = [ - os.path.expanduser("~/Library/Frameworks"), - "/Library/Frameworks", + os.path.expanduser("~/Library/Frameworks"), + "/Library/Frameworks", "/Network/Library/Frameworks" ] -LOCAL_LIBPATH = filter(lambda x: - os.path.isdir(x), - ["/usr/local/lib", "/opt/local/lib", "/sw/local/lib"] -) +LOCAL_LIBPATH = list(filter( + lambda x: os.path.isdir(x), + ["/usr/local/lib", "/opt/local/lib", "/sw/local/lib"])) #however FRAMEWORKS = LOCAL_FRAMEWORKS + SYSTEM_FRAMEWORKS @@ -71,7 +70,7 @@ def otool(binary): "Do not run this on object code archive (.a) files, it is not designed for that." #if not os.path.exists(binary): raise Exception("'%s' not found." % binary) if not type(binary) == str: raise ValueError("otool() requires a path (as a string)") - print "otool(%s)" % binary + print("otool(%s)" % binary) stdin, stdout, stderr = os.popen3('otool -L "%s"' % binary) try: header = stdout.readline() #discard the first line since it is just the name of the file or an error message (or if reading .as, the first item on the list) @@ -101,7 +100,7 @@ def dependencies(binary): #This will work in probably every library that exists in reality, so it's "ok" if os.path.basename(l[0]) == os.path.basename(binary): id = l.pop(0) - #print "Removing -id field result %s from %s" % (id, binary) + #print("Removing -id field result %s from %s" % (id, binary)) return l @@ -154,7 +153,7 @@ def embed_dependencies(binary, for P in ['']+LOCAL+SYSTEM: #XXX should local have priority over system or vice versa? (also, '' is the handle the relative case) p = os.path.abspath(os.path.join(P, e)) - #print "SEARCHING IN LIBPATH; TRYING", p + #print("SEARCHING IN LIBPATH; TRYING", p) if os.path.exists(p): break else: |