preprocess_frozen_modules.py: yet more Python 3.4 compatibility changes
This commit is contained in:
parent
644ad74ea1
commit
31be20744d
|
@ -6,15 +6,16 @@ from pathlib import Path
|
||||||
import semver
|
import semver
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
# Compatible with Python 3.4 due to travis using trusty as default.
|
||||||
|
|
||||||
def version_string(path=None, *, valid_semver=False):
|
def version_string(path=None, *, valid_semver=False):
|
||||||
version = None
|
version = None
|
||||||
tag = subprocess.run('git describe --tags --exact-match', shell=True,
|
try:
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path)
|
tag = subprocess.check_output('git describe --tags --exact-match', shell=True, cwd=path)
|
||||||
if tag.returncode == 0:
|
version = tag.strip().decode("utf-8", "strict")
|
||||||
version = tag.stdout.strip().decode("utf-8", "strict")
|
except subprocess.CalledProcessError:
|
||||||
else:
|
describe = subprocess.check_output("git describe --tags", shell=True, cwd=path)
|
||||||
describe = subprocess.run("git describe --tags", shell=True, stdout=subprocess.PIPE, cwd=path)
|
tag, additional_commits, commitish = describe.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2)
|
||||||
tag, additional_commits, commitish = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2)
|
|
||||||
commitish = commitish[1:]
|
commitish = commitish[1:]
|
||||||
if valid_semver:
|
if valid_semver:
|
||||||
version_info = semver.parse_version_info(tag)
|
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))
|
output_file_path = Path(out_dir, input_file_path.relative_to(in_dir))
|
||||||
|
|
||||||
if file.endswith(".py"):
|
if file.endswith(".py"):
|
||||||
# mkdir() takes an exists_ok=True, but not until Python 3.5.
|
|
||||||
if not output_file_path.parent.exists():
|
if not output_file_path.parent.exists():
|
||||||
output_file_path.parent.mkdir(parents=True)
|
output_file_path.parent.mkdir(parents=True)
|
||||||
with input_file_path.open("r") as input, output_file_path.open("w") as output:
|
with input_file_path.open("r") as input, output_file_path.open("w") as output:
|
||||||
|
|
Loading…
Reference in New Issue