diff options
| author | Dan Halbert <halbert@halwitz.org> | 2017-12-24 14:29:03 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2017-12-24 14:29:03 -0500 |
| commit | 31be20744deaeb24a18205fc8099d2628531830d (patch) | |
| tree | a12f371db95f4f8b5e32a25258d9c5c6a86d6875 /tools | |
| parent | 644ad74ea1a33ef7112da1537e83c802b2b15202 (diff) | |
preprocess_frozen_modules.py: yet more Python 3.4 compatibility changes
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/preprocess_frozen_modules.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index b425ffa2d..0233fba61 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -6,15 +6,16 @@ from pathlib import Path import semver import subprocess +# Compatible with Python 3.4 due to travis using trusty as default. + def version_string(path=None, *, valid_semver=False): version = None - tag = subprocess.run('git describe --tags --exact-match', shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path) - if tag.returncode == 0: - version = tag.stdout.strip().decode("utf-8", "strict") - else: - describe = subprocess.run("git describe --tags", shell=True, stdout=subprocess.PIPE, cwd=path) - tag, additional_commits, commitish = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) + try: + tag = subprocess.check_output('git describe --tags --exact-match', shell=True, cwd=path) + version = tag.strip().decode("utf-8", "strict") + except subprocess.CalledProcessError: + describe = subprocess.check_output("git describe --tags", shell=True, cwd=path) + tag, additional_commits, commitish = describe.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) commitish = commitish[1:] if valid_semver: version_info = semver.parse_version_info(tag) @@ -45,7 +46,6 @@ def copy_and_process(in_dir, out_dir): output_file_path = Path(out_dir, input_file_path.relative_to(in_dir)) if file.endswith(".py"): - # mkdir() takes an exists_ok=True, but not until Python 3.5. if not output_file_path.parent.exists(): output_file_path.parent.mkdir(parents=True) with input_file_path.open("r") as input, output_file_path.open("w") as output: |
