|
35 | 35 |
|
36 | 36 | # version handling |
37 | 37 | version_file = 'bpython/_version.py' |
| 38 | +version = 'unkown' |
38 | 39 |
|
39 | 40 | try: |
40 | 41 | # get version from git describe |
41 | | - version = subprocess.check_output(['git', 'describe', '--tags']).rstrip() |
42 | | - version_split = version.split('-') |
43 | | - if len(version_split) == 4: |
44 | | - # format: version-release-commits-hash |
45 | | - version = '-'.join((version_split[0], version_split[2])) |
46 | | - elif len(version_split) == 2: |
47 | | - # format: version-release |
48 | | - version = version_split[0] |
49 | | -except subprocess.CalledProcessError: |
| 42 | + proc = subprocess.Popen(['git', 'describe', '--tags'], |
| 43 | + stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 44 | + stdout = proc.communicate()[0].rstrip() |
| 45 | + |
| 46 | + if proc.returncode == 0: |
| 47 | + version_split = stdout.split('-') |
| 48 | + if len(version_split) == 4: |
| 49 | + # format: version-release-commits-hash |
| 50 | + version = '-'.join((version_split[0], version_split[2])) |
| 51 | + elif len(version_split) == 2: |
| 52 | + # format: version-release |
| 53 | + version = version_split[0] |
| 54 | +except OSError: |
| 55 | + pass |
| 56 | + |
| 57 | +if version == 'unknown': |
50 | 58 | try: |
51 | 59 | # get version from existing version file |
52 | 60 | with open(version_file) as vf: |
53 | 61 | version = vf.read().strip().split('=')[-1].replace('\'', '') |
54 | 62 | except IOError: |
55 | | - version = 'unknown' |
| 63 | + pass |
56 | 64 |
|
57 | 65 | with open(version_file, 'w') as vf: |
58 | 66 | vf.write('# Auto-generated file, do not edit!\n') |
|
0 commit comments