From 249c83f14b282cec027d499daa843838db943614 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Thu, 26 Aug 2021 09:44:02 -0700 Subject: [PATCH] build: Fix additional python2/3 issues The generate_version_string script was only producing correct results in python 2, not python 3. The gyp file that references it explicitly runs it in python3. The shebang line of the script has been updated to match. The script itself has been updated such that it now works correctly in both python2 and python3. Scripts that are only used as modules (not executed directly) have had their shebang lines removed. This fixes CI failures on GitHub Actions. Change-Id: I309bafd2fb05e8fb33f5e092ead179c8c42ea5d3 --- packager/app/test/packager_app.py | 2 -- packager/app/test/test_env.py | 2 -- packager/version/generate_version_string.py | 8 ++++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packager/app/test/packager_app.py b/packager/app/test/packager_app.py index 74bef7d217..834f736125 100644 --- a/packager/app/test/packager_app.py +++ b/packager/app/test/packager_app.py @@ -1,5 +1,3 @@ -#!/usr/bin/python -# # Copyright 2014 Google Inc. All Rights Reserved. # # Use of this source code is governed by a BSD-style diff --git a/packager/app/test/test_env.py b/packager/app/test/test_env.py index 8f3de3b3ca..951e9de586 100644 --- a/packager/app/test/test_env.py +++ b/packager/app/test/test_env.py @@ -1,5 +1,3 @@ -#!/usr/bin/python -# # Copyright 2014 Google Inc. All Rights Reserved. # # Use of this source code is governed by a BSD-style diff --git a/packager/version/generate_version_string.py b/packager/version/generate_version_string.py index ae263873e7..460c6b4ba7 100755 --- a/packager/version/generate_version_string.py +++ b/packager/version/generate_version_string.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright 2015 Google Inc. All rights reserved. # @@ -12,7 +12,7 @@ import subprocess if __name__ == '__main__': try: version_tag = subprocess.check_output('git tag --points-at HEAD', - stderr=subprocess.STDOUT, shell=True).rstrip() + stderr=subprocess.STDOUT, shell=True).decode().rstrip() except subprocess.CalledProcessError as e: # git tag --points-at is not supported in old versions of git. Just ignore # version_tag in this case. @@ -20,11 +20,11 @@ if __name__ == '__main__': try: version_hash = subprocess.check_output('git rev-parse --short HEAD', - stderr=subprocess.STDOUT, shell=True).rstrip() + stderr=subprocess.STDOUT, shell=True).decode().rstrip() except subprocess.CalledProcessError as e: version_hash = 'unknown-version' if version_tag: print('{0}-{1}'.format(version_tag, version_hash)) else: - print(version_hash.decode('utf8')) + print(version_hash)