diff --git a/Makefile b/Makefile index 583735d..d61e41d 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,6 @@ clean: rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist pybuild: - # Set version in Python - sed -i cloudbender/__init__.py -e 's/__version__.*/__version__ = "$(TAG)"/' python setup.py bdist_wheel --universal test_upload: $(PACKAGE_FILE) diff --git a/cloudbender/__init__.py b/cloudbender/__init__.py index 25ff8a5..5961f1d 100644 --- a/cloudbender/__init__.py +++ b/cloudbender/__init__.py @@ -1,8 +1,13 @@ import logging +import pkg_resources __author__ = "Stefan Reimer" __email__ = "stefan@zero-downtimet.net" -__version__ = "v0.10.3" + +try: + __version__ = pkg_resources.get_distribution("CloudBender").version +except pkg_resources.DistributionNotFound: + __version__ = "devel" # Set up logging to ``/dev/null`` like a library is supposed to. diff --git a/setup.cfg b/setup.cfg index 6fedc19..ed32940 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -description-file = README.md +description_file = README.md [bdist_wheel] universal=1 diff --git a/setup.py b/setup.py index f599619..46c5f4c 100644 --- a/setup.py +++ b/setup.py @@ -6,17 +6,6 @@ from setuptools import setup from setuptools import find_packages from setuptools.command.test import test as TestCommand -def find_version(filename): - """Uses re to pull out the assigned value to __version__ in filename.""" - - with io.open(filename, "r", encoding="utf-8") as version_file: - version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', - version_file.read(), re.M) - if version_match: - return version_match.group(1) - return "0.0-version-unknown" - - class PyTest(TestCommand): """TestCommand subclass to use pytest with setup.py test.""" @@ -45,7 +34,10 @@ else: setup( name='cloudbender', - version=find_version("cloudbender/__init__.py"), + setuptools_git_versioning={ + "enabled": True, + }, + setup_requires=["setuptools-git-versioning"], description='Toolset to render and manage AWS Cloudformation', python_requires='>=3.7', long_description=long_description,