Skip to content

Commit

Permalink
Removed usage of deprecated pkg_resources
Browse files Browse the repository at this point in the history
Define version instead in polymorphic/__init__.py file.
  • Loading branch information
sliverc committed Apr 25, 2023
1 parent bd5faf0 commit 4b7be85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 1 addition & 6 deletions polymorphic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 11 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import os
import re
import sys

from setuptools import find_packages, setup
Expand All @@ -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"),
)

0 comments on commit 4b7be85

Please sign in to comment.