diff --git a/polymorphic/__init__.py b/polymorphic/__init__.py index 128269f9..bb57871c 100644 --- a/polymorphic/__init__.py +++ b/polymorphic/__init__.py @@ -6,9 +6,4 @@ Please see LICENSE and AUTHORS for more information. """ -import pkg_resources - -try: - __version__ = pkg_resources.require("django-polymorphic")[0].version -except pkg_resources.DistributionNotFound: - __version__ = None # for RTD among others +__version__ = "3.1.0" diff --git a/setup.cfg b/setup.cfg index 09ff55a5..a3d7c9c7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = django-polymorphic -version = 3.1.0 description = Seamless polymorphic inheritance for Django models long_description = file:README.rst author = Bert Constantin diff --git a/setup.py b/setup.py index a8677b14..ebb91708 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import os +import re import sys from setuptools import find_packages, setup @@ -19,4 +20,13 @@ from setuptools import setup -setup() +def get_version(package): + """ + Return package version as listed in `__version__` in `init.py`. + """ + init_py = open(os.path.join(package, "__init__.py")).read() + return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1) + +setup( + version=get_version("polymorphic"), +)