From 345e25e9594d6fcf0fe1b55c4f640106437467de Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Fri, 23 Nov 2018 17:23:38 +0100 Subject: [PATCH] Make version accessible from within python --- setup.py | 24 ++++++++++++++++++------ trixi/__init__.py | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 977e7cf..e7e6c19 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os +import re from setuptools import setup @@ -15,17 +16,28 @@ def resolve_requirements(file): return requirements -with open(os.path.join(os.path.dirname(__file__), "Readme.md")) as f: - readme = f.read() +def read_file(file): + with open(file) as f: + content = f.read() + return content + + +def find_version(file): + content = read_file(file) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") -with open(os.path.join(os.path.dirname(__file__), "LICENSE")) as f: - license = f.read() required = resolve_requirements(os.path.join(os.path.dirname(__file__), 'requirements_full.txt')) +readme = read_file(os.path.join(os.path.dirname(__file__), "Readme.md")) +license = read_file(os.path.join(os.path.dirname(__file__), "LICENSE")) +version = find_version(os.path.join(os.path.dirname(__file__), "trixi", "__init__.py")) setup(name='trixi', - version='0.1.0.1', - description='Package to log visualizations and experiments, e.g. with visdom', + version=version, + description='Manage your machine learning experiments with trixi - modular, reproducible, high fashion', long_description=readme, long_description_content_type="text/markdown", url='https://github.com/MIC-DKFZ/trixi', diff --git a/trixi/__init__.py b/trixi/__init__.py index d6fa52c..1d33122 100644 --- a/trixi/__init__.py +++ b/trixi/__init__.py @@ -1,3 +1,5 @@ use_agg = True import matplotlib if use_agg: matplotlib.use("Agg", warn=False) + +__version__ = "0.1.1.0"