-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from electronic-structure/develop
Develop
- Loading branch information
Showing
33 changed files
with
730 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.8.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import sys | ||
import subprocess | ||
import datetime | ||
import json | ||
|
||
# Use github REST API to query the tags | ||
request_str = 'https://api.github.com/repos/electronic-structure/SIRIUS/tags' | ||
|
||
def to_string(s): | ||
""" | ||
Convert to ASCII sring. | ||
""" | ||
if isinstance(s, str): | ||
return s | ||
else: | ||
return s.decode('utf-8') | ||
|
||
def get_sha(vstr): | ||
""" | ||
Get SHA hash of the code. | ||
Try to call git. If git command is not found or this is not a git repository, try to read | ||
the file VERSION to get the tag name. If none found, return an empty string. | ||
""" | ||
|
||
sha_str = "" | ||
|
||
try: | ||
p = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
sha_str = p.communicate()[0].strip() | ||
if p.returncode != 0: raise | ||
except: | ||
# python2 and python3 handle URL requests differently | ||
if sys.version_info < (3, 0): | ||
import urllib2 | ||
data = json.load(urllib2.urlopen(request_str)) | ||
else: | ||
import urllib.request | ||
req = urllib.request.Request(request_str) | ||
data = json.load(urllib.request.urlopen(req)) | ||
# serach for a version tag | ||
for e in data: | ||
if e['name'] == 'v' + vstr: | ||
sha_str = e['commit']['sha'] | ||
break | ||
|
||
return to_string(sha_str) | ||
|
||
def get_branch(sha_str, vstr): | ||
""" | ||
Get name of the branch. If git command failed but SHA is found, this is a release version | ||
""" | ||
branch_name = "" | ||
try: | ||
p = subprocess.Popen(["git", "describe", "--all"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
branch_name = p.communicate()[0].strip() | ||
if p.returncode != 0: raise | ||
except: | ||
if sha_str: | ||
branch_name = 'release tag v%s'%vstr | ||
return to_string(branch_name) | ||
|
||
def main(): | ||
print("/** \\file version.hpp") | ||
print(" * \\brief Auto-generated version file.") | ||
print(" */\n") | ||
print("#ifndef __VERSION_HPP__") | ||
print("#define __VERSION_HPP__") | ||
|
||
now = datetime.datetime.now() | ||
|
||
version_str = "" | ||
# get version string from the file | ||
try: | ||
with open(sys.argv[1]) as vf: | ||
version_str = vf.readline().strip() | ||
except: | ||
pass | ||
sha_str = get_sha(version_str) | ||
branch_name = get_branch(sha_str, version_str) | ||
|
||
print("const char* const git_hash = \"%s\";"%sha_str) | ||
print("const char* const git_branchname = \"%s\";"%branch_name) | ||
#print("const char* const build_date = \"%s\";"%(now.strftime("%a, %e %b %Y %H:%M:%S"))) | ||
print("#endif") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.