Switch to setuptools-scm.

This commit is contained in:
Jannis Leidel 2019-12-03 13:01:17 +01:00
parent bd61710591
commit 42641f5eb4
No known key found for this signature in database
GPG key ID: C795956FB489DCA9
8 changed files with 25 additions and 33 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ htmlcov/
*.pyc
dist/
tests/docs/_build/
.eggs/

View file

@ -1,8 +1,8 @@
# flake8: noqa
from .base import Configuration
from .decorators import pristinemethod
from .base import Configuration # noqa
from .decorators import pristinemethod # noqa
from .version import __version__ # noqa
__version__ = '2.1'
__all__ = ['Configuration', 'pristinemethod']

View file

@ -128,8 +128,8 @@ class ConfigurationImporter(object):
and os.environ.get('RUN_MAIN') == 'true'):
message = ("django-configurations version {0}, using "
"configuration '{1}'".format(__version__,
self.name))
"configuration {1}".format(__version__ or "",
self.name))
self.logger.debug(stylize(message))
def find_module(self, fullname, path=None):

View file

@ -0,0 +1,7 @@
from pkg_resources import get_distribution, DistributionNotFound
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
__version__ = None

View file

@ -18,7 +18,8 @@ v2.2 (2019-12-03)
- Replace ``django.utils.six`` with ``six`` to support Django >= 3.
- Start using tox-travis for simplified test harness management.
- Start using tox-travis and setuptools-scm for simplified test harness
and release management.
v2.1 (2018-08-16)
^^^^^^^^^^^^^^^^^

View file

@ -14,6 +14,8 @@
import sys
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
# documentation root, use os.path.abspath to make it absolute, like shown here.
@ -48,14 +50,10 @@ copyright = u'2012-2014, Jannis Leidel and other contributors'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
try:
from configurations import __version__
# The short X.Y version.
version = '.'.join(__version__.split('.')[:2])
# The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = 'dev'
# The full version, including alpha/beta/rc tags.
release = get_distribution("django-configurations").version
# The short X.Y version.
version = ".".join(release.split(".")[:2])
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -9,5 +9,5 @@ parallel = 1
include = configurations/*,tests/*
[flake8]
exclude = .tox,docs/*
exclude = .tox,docs/*,.eggs
ignore = E501,E127,E128,E124,W503

View file

@ -1,34 +1,19 @@
from __future__ import print_function
import ast
import os
import codecs
from setuptools import setup
class VersionFinder(ast.NodeVisitor):
def __init__(self):
self.version = None
def visit_Assign(self, node):
if node.targets[0].id == '__version__':
self.version = node.value.s
def read(*parts):
filename = os.path.join(os.path.dirname(__file__), *parts)
with codecs.open(filename, encoding='utf-8') as fp:
return fp.read()
def find_version(*parts):
finder = VersionFinder()
finder.visit(ast.parse(read(*parts)))
return finder.version
setup(
name="django-configurations",
version=find_version("configurations", "__init__.py"),
use_scm_version={"version_scheme": "post-release", "local_scheme": "dirty-tag"},
setup_requires=["setuptools_scm"],
url='https://django-configurations.readthedocs.io/',
license='BSD',
description="A helper for organizing Django settings.",