From 4fdf79fa1f33f37f6e39a9d823c7843abfd6ed1a Mon Sep 17 00:00:00 2001 From: Felix Zimmermann Date: Wed, 21 Apr 2021 02:17:40 +0200 Subject: [PATCH] version --- .github/workflows/publish.yml | 9 +++------ idi/__init__.py | 2 +- setup.py | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 162f22e..a729e6a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,11 +17,10 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: | VERSION=$(echo $GITHUB_REF | sed 's#refs/tags/##') - echo "$VERSION" PLACEHOLDER="develop" VERSION_FILE='idi/__init__.py' grep "__version__.*$PLACEHOLDER" "$VERSION_FILE" - sed -Ei "s/(__version__ ?=.*)-$PLACEHOLDER/\1-$VERSION/g" "$VERSION_FILE" + sed -E -i'.original' -e "s/(__version__ ?=.*)\+$PLACEHOLDER/\1\+$VERSION/g" "$VERSION_FILE" cat "$VERSION_FILE" shell: bash @@ -64,11 +63,10 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: | VERSION=$(echo $GITHUB_REF | sed 's#refs/tags/##') - echo "$VERSION" PLACEHOLDER="develop" VERSION_FILE='idi/__init__.py' grep "__version__.*$PLACEHOLDER" "$VERSION_FILE" - sed -Ei "s/(__version__ ?=.*)-$PLACEHOLDER/\1-$VERSION/g" "$VERSION_FILE" + sed -E -i'.original' -e "s/(__version__ ?=.*)\+$PLACEHOLDER/\1\+$VERSION/g" "$VERSION_FILE" cat "$VERSION_FILE" shell: bash @@ -134,11 +132,10 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: | VERSION=$(echo $GITHUB_REF | sed 's#refs/tags/##') - echo "$VERSION" PLACEHOLDER="develop" VERSION_FILE='idi/__init__.py' grep "__version__.*$PLACEHOLDER" "$VERSION_FILE" - sed -Ei "s/(__version__ ?=.*)-$PLACEHOLDER/\1-$VERSION/g" "$VERSION_FILE" + sed -E -i'.original' -e "s/(__version__ ?=.*)\+$PLACEHOLDER/\1\+$VERSION/g" "$VERSION_FILE" cat "$VERSION_FILE" shell: bash diff --git a/idi/__init__.py b/idi/__init__.py index 1d073cb..505c744 100644 --- a/idi/__init__.py +++ b/idi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.0.0-develop" +__version__ = "0.0.0+develop" __all__ = ['reconstruction', 'simulation', 'util'] # from . import simulation,reconstruction diff --git a/setup.py b/setup.py index 7cfd303..2760534 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ def configuration(): from collections import OrderedDict import numpy - config = Configuration("idi", "") + config = Configuration("idi","") srcdir = join(dirname(realpath(__file__)), "idi") mkl_info = get_info("mkl") basedirs = list( @@ -113,11 +113,24 @@ def configuration(): return config +def get_version(rel_path): + import os.path + import codecs + + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, rel_path), "r") as fp: + for line in fp.read().splitlines(): + if line.startswith("__version__"): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + raise RuntimeError("Unable to find version string.") + + def setup_package(): from numpy.distutils.core import setup - import idi as app - + metadata = dict( + version=get_version("idi/__init__.py"), maintainer="zimmf", description="idi simulation and reconstruction", platforms=["Linux", "Mac OS-X"], @@ -136,10 +149,9 @@ def setup_package(): "mkl-include", ], package_data={"": ["*.cu"]}, - version=app.__version__, scripts=["scripts/idi_sim.py", "scripts/idi_simrecon.py"], - configuration=configuration, test_suite="tests", + **configuration().todict() ) setup(**metadata)