diff --git a/pyfstat/__init__.py b/pyfstat/__init__.py index 9036370f0e8a8472fedbc476d2249f61e934430c..6af2b7e990bbe90d4adf122937cc0f17b260541f 100644 --- a/pyfstat/__init__.py +++ b/pyfstat/__init__.py @@ -29,4 +29,5 @@ from .grid_based_searches import ( from .helper_functions import get_version_information + __version__ = get_version_information() diff --git a/pyfstat/helper_functions.py b/pyfstat/helper_functions.py index 063876a01a1e90a047dd7dc90da88c28c457ac36..806d485db4a4d238d0fcb3c92cfb4b75d1c2e4f9 100644 --- a/pyfstat/helper_functions.py +++ b/pyfstat/helper_functions.py @@ -394,9 +394,10 @@ def match_commandlines(cl1, cl2, be_strict_about_full_executable_path=False): def get_version_information(): version_file = os.path.join( - os.path.dirname(os.path.dirname(__file__)), 'pyfstat/.version') + os.path.dirname(os.path.dirname(__file__)), "pyfstat/.version" + ) try: - with open(version_file, 'r') as f: + with open(version_file, "r") as f: return f.readline().rstrip() except EnvironmentError: print("No version information file '.version' found") diff --git a/setup.py b/setup.py index 65bd30650f060ddeaefa715b89b6c1464026514c..64a0f1c53d560cedc9920710b2aff8513348a0a8 100644 --- a/setup.py +++ b/setup.py @@ -22,24 +22,25 @@ def write_version_file(version): """ try: git_log = subprocess.check_output( - ['git', 'log', '-1', '--pretty=%h %ai']).decode('utf-8') - git_diff = (subprocess.check_output(['git', 'diff', '.']) + - subprocess.check_output( - ['git', 'diff', '--cached', '.'])).decode('utf-8') - if git_diff == '': - git_status = '(CLEAN) ' + git_log + ["git", "log", "-1", "--pretty=%h %ai"] + ).decode("utf-8") + git_diff = ( + subprocess.check_output(["git", "diff", "."]) + + subprocess.check_output(["git", "diff", "--cached", "."]) + ).decode("utf-8") + if git_diff == "": + git_status = "(CLEAN) " + git_log else: - git_status = '(UNCLEAN) ' + git_log + git_status = "(UNCLEAN) " + git_log except Exception as e: - print("Unable to obtain git version information, exception: {}" - .format(e)) - git_status = '' + print("Unable to obtain git version information, exception: {}".format(e)) + git_status = "" - version_file = '.version' + version_file = ".version" if path.isfile(version_file) is False: - with open('pyfstat/' + version_file, 'w+') as f: - f.write('{}: {}'.format(version, git_status)) - print('Done', version_file, version, git_status) + with open("pyfstat/" + version_file, "w+") as f: + f.write("{}: {}".format(version, git_status)) + print("Done", version_file, version, git_status) return version_file @@ -61,7 +62,7 @@ here = path.abspath(path.dirname(__file__)) with open(path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() -VERSION = '1.3' +VERSION = "1.3" version_file = write_version_file(VERSION) setup( @@ -79,7 +80,7 @@ setup( "pyfstat": [ "pyCUDAkernels/cudaTransientFstatExpWindow.cu", "pyCUDAkernels/cudaTransientFstatRectWindow.cu", - version_file + version_file, ] }, python_requires=">=%s.%s.%s" % min_python_version[:3],