|
6 | 6 | import semver
|
7 | 7 | import subprocess
|
8 | 8 |
|
| 9 | +# Compatible with Python 3.4 due to travis using trusty as default. |
| 10 | + |
9 | 11 | def version_string(path=None, *, valid_semver=False):
|
10 | 12 | version = None
|
11 |
| - tag = subprocess.run('git describe --tags --exact-match', shell=True, |
12 |
| - stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path) |
13 |
| - if tag.returncode == 0: |
14 |
| - version = tag.stdout.strip().decode("utf-8", "strict") |
15 |
| - else: |
16 |
| - describe = subprocess.run("git describe --tags", shell=True, stdout=subprocess.PIPE, cwd=path) |
17 |
| - tag, additional_commits, commitish = describe.stdout.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) |
| 13 | + try: |
| 14 | + tag = subprocess.check_output('git describe --tags --exact-match', shell=True, cwd=path) |
| 15 | + version = tag.strip().decode("utf-8", "strict") |
| 16 | + except subprocess.CalledProcessError: |
| 17 | + describe = subprocess.check_output("git describe --tags", shell=True, cwd=path) |
| 18 | + tag, additional_commits, commitish = describe.strip().decode("utf-8", "strict").rsplit("-", maxsplit=2) |
18 | 19 | commitish = commitish[1:]
|
19 | 20 | if valid_semver:
|
20 | 21 | version_info = semver.parse_version_info(tag)
|
@@ -45,7 +46,6 @@ def copy_and_process(in_dir, out_dir):
|
45 | 46 | output_file_path = Path(out_dir, input_file_path.relative_to(in_dir))
|
46 | 47 |
|
47 | 48 | if file.endswith(".py"):
|
48 |
| - # mkdir() takes an exists_ok=True, but not until Python 3.5. |
49 | 49 | if not output_file_path.parent.exists():
|
50 | 50 | output_file_path.parent.mkdir(parents=True)
|
51 | 51 | with input_file_path.open("r") as input, output_file_path.open("w") as output:
|
|
0 commit comments