-
Notifications
You must be signed in to change notification settings - Fork 3
/
makeModule.py
executable file
·29 lines (23 loc) · 1.1 KB
/
makeModule.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
#!/usr/bin/env python3
###################################################################################
# Copyright 2021 National Technology & Engineering Solutions of Sandia, #
# LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the #
# U.S. Government retains certain rights in this software. #
# If you want to use this code, please refer to the README.rst and LICENSE files. #
###################################################################################
from sys import argv
from subprocess import Popen, PIPE
from pathlib import Path
from datetime import datetime
assert len(argv) == 3
moduleFile = argv[1]
installLocation = Path(argv[2]).resolve()
proc = Popen('git describe --always --dirty --abbrev=40', shell=True, stdout=PIPE)
proc.wait()
sha = proc.stdout.read()
sha = sha[:-1].decode('utf-8')
with open(moduleFile, 'w') as f:
f.write('whatis("Version: {}")\n'.format(sha))
f.write('whatis("BuildDate: {}")\n'.format(datetime.now()))
f.write('\n')
f.write('prepend_path(\"PYTHONPATH\", \"{}\")\n'.format(installLocation))