Use setuptools_scm

This commit is contained in:
Jannis Leidel 2020-11-29 14:39:17 +01:00
parent 0ce2501384
commit 2cd07a9e89
No known key found for this signature in database
GPG key ID: C795956FB489DCA9
3 changed files with 16 additions and 21 deletions

View file

@ -10,7 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import os
from pkg_resources import get_distribution
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@ -44,20 +45,13 @@ copyright = '2015, Carl Meyer'
parent_dir = os.path.dirname(os.path.dirname(__file__))
def get_version():
with open(os.path.join(parent_dir, 'model_utils', '__init__.py')) as f:
for line in f:
if line.startswith('__version__ ='):
return line.split('=')[1].strip().strip('"\'')
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = get_version()
# The short X.Y version.
version = release
release = get_distribution('django-model-utils').version
# for example take major/minor
version = '.'.join(release.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -1,4 +1,10 @@
from pkg_resources import get_distribution, DistributionNotFound
from .choices import Choices # noqa:F401
from .tracker import FieldTracker, ModelTracker # noqa:F401
__version__ = '4.0.1'
try:
__version__ = get_distribution("django-model-utils").version
except DistributionNotFound:
# package is not installed
pass

View file

@ -15,23 +15,18 @@ HERE = os.path.abspath(os.path.dirname(__file__))
long_description = "\n\n".join(long_desc(HERE))
def get_version(root_path):
with open(os.path.join(root_path, 'model_utils', '__init__.py')) as f:
for line in f:
if line.startswith('__version__ ='):
return line.split('=')[1].strip().strip('"\'')
setup(
name='django-model-utils',
version=get_version(HERE),
use_scm_version={"version_scheme": "post-release"},
setup_requires=["setuptools_scm"],
license="BSD",
description='Django model mixins and utilities',
long_description=long_description,
long_description_content_type='text/x-rst',
author='Carl Meyer',
author_email='carl@oddbird.net',
maintainer='JazzBand',
url='https://github.com/jazzband/django-model-utils/',
url='https://github.com/jazzband/django-model-utils',
packages=find_packages(exclude=['tests*']),
install_requires=['Django>=2.0.1'],
classifiers=[