-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_version.py
37 lines (31 loc) · 1.16 KB
/
check_version.py
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
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""Check that version numbers match.
Check version number in setup.json and aiida_flexpart/__init__.py and make sure
they match.
"""
from __future__ import absolute_import
from __future__ import print_function
import os
import json
import sys
this_path = os.path.split(os.path.realpath(__file__))[0]
# Get content of setup.json
SETUP_FNAME = 'setup.json'
SETUP_PATH = os.path.join(this_path, os.pardir, SETUP_FNAME)
with open(SETUP_PATH) as f:
setup_content = json.load(f)
# Get version from python package
sys.path.insert(0, os.path.join(this_path, os.pardir))
import aiida_flexpart # pylint: disable=wrong-import-position
VERSION = aiida_flexpart.__version__
if VERSION != setup_content['version']:
print('Version number mismatch detected:')
print("Version number in '{}': {}".format(SETUP_FNAME,
setup_content['version']))
print("Version number in '{}/__init__.py': {}".format(
'aiida_flexpart', VERSION))
sys.exit(1)
# Overwrite version in setup.json
#setup_content['version'] = version
#with open(SETUP_PATH, 'w') as f:
# json.dump(setup_content, f, indent=4, sort_keys=True)