aboutsummaryrefslogtreecommitdiff
path: root/.ci/package-version.py
blob: bbf2ff4ba63b2ee7ba736a2b6058ca254e30b2ec (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3


import os.path
import sys


def main():
    version_file = os.path.join(
        os.path.dirname(os.path.dirname(__file__)),
        'immutables', '__init__.py')

    with open(version_file, 'r') as f:
        for line in f:
            if line.startswith('__version__ ='):
                _, _, version = line.partition('=')
                print(version.strip(" \n'\""))
                return 0

    print('could not find package version in immutables/__init__.py',
          file=sys.stderr)
    return 1


if __name__ == '__main__':
    sys.exit(main())